-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Add labels for root parent object #14578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Scott Fleener <[email protected]>
e57df5a
to
1d643ee
Compare
controller/k8s/metadata_api.go
Outdated
|
||
resource := schema.FromAPIVersionAndKind(parentRef.APIVersion, parentRef.Kind). | ||
GroupVersion(). | ||
WithResource(parentRef.Kind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part doesn't seem to work consistently, not sure if there's a better way to generate a GroupVersionResource
from a parent ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances it's not consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 11ca6b1, turns out it was actually incorrect since "resource" is a subtly different format from "kind"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
I guess the path forward is to remove the old logic along with its labels. If so, can you flag that in the the the labels.go
's label entry godoc? Should also be mentioned in the release notes.
if err != nil { | ||
return Address{}, PodID{}, err | ||
} | ||
ownerKind, ownerName := pp.metadataAPI.GetOwnerKindAndName(context.Background(), pod, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts about replacing this with the new function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. I can put out a follow-up for this, since the current implementation doesn't support controlling retry logic.
ownerKind, ownerName := wp.metadataAPI.GetOwnerKindAndName(context.Background(), wp.addr.Pod, true) | ||
wp.addr.OwnerKind = ownerKind | ||
wp.addr.OwnerName = ownerName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, saving for follow-up
controller/k8s/api_test.go
Outdated
api.Sync(nil) | ||
metadataAPI.Sync(nil) | ||
} | ||
metadataAPI.Sync(nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this was actually incorrect, since the API expects resources in a different format than I was using.
The GroupVersionResource requires the resource to be both lowercase and plural. Signed-off-by: Scott Fleener <[email protected]>
Signed-off-by: Scott Fleener <[email protected]>
Currently, we add a label that identifies the parent resource that a proxy is attached to, usually a deployment, statefulset, daemonset, etc. These are populated via
linkerd.io/proxy-<resource>
annotations, with a different label for each parent resource.There are a few deficiencies with the current implementation. Currently, the implementation is specialized to only built-in k8s resources, so things like argocd rollouts will not appear. Additionally it does not recurse beyond two levels, so any more levels of parenting will not be captured.
This adds a pair of new labels,
linkerd.io/proxy-root-parent
andlinkerd.io/proxy-root-parent-kind
, that identify the name and kind of the root parent of a proxy workload. It also correctly recurses to the true root resource, at least as far as cluster role permissions for the proxy injector permit.Note that the proxy already consumes all of the pod labels via the downward API, so there's no changes required to the proxy injector templates.