Skip to content

Conversation

sfleen
Copy link
Contributor

@sfleen sfleen commented Oct 6, 2025

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 and linkerd.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.

@sfleen sfleen force-pushed the sfleen/trace-parent branch from e57df5a to 1d643ee Compare October 6, 2025 18:08
@sfleen sfleen changed the title feat: Add label for root parent object feat: Add labels for root parent object Oct 6, 2025

resource := schema.FromAPIVersionAndKind(parentRef.APIVersion, parentRef.Kind).
GroupVersion().
WithResource(parentRef.Kind)
Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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"

@sfleen sfleen marked this pull request as ready for review October 6, 2025 18:29
@sfleen sfleen requested a review from a team as a code owner October 6, 2025 18:29
@sfleen sfleen requested a review from alpeb October 6, 2025 18:30
Copy link
Member

@alpeb alpeb left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Comment on lines +698 to +700
ownerKind, ownerName := wp.metadataAPI.GetOwnerKindAndName(context.Background(), wp.addr.Pod, true)
wp.addr.OwnerKind = ownerKind
wp.addr.OwnerName = ownerName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

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

api.Sync(nil)
metadataAPI.Sync(nil)
}
metadataAPI.Sync(nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍

Copy link
Contributor Author

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.

sfleen added 3 commits October 6, 2025 16:25
The GroupVersionResource requires the resource to be both lowercase and plural.

Signed-off-by: Scott Fleener <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants