Skip to content
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

#70 Support ArgoCD Resource tracking #366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BerndFarkaDyna
Copy link

@BerndFarkaDyna BerndFarkaDyna commented Mar 9, 2025

This PR enables Tracking of child resources of a Kro created Resource (#70)

  • Implemented propagation of app.kubernetes.io/appinstance label
  • implemented propagation of OnwerReferences

This PR supports the Resources Tracking of ArgoCD via Labels and Annoations

…e label and add ownership information on sub resources

feat: Implement ArgoCD App tracking support, propagate K8s AppInstance label and add ownership information on sub resources

Remove controller-pod-id label

This label is not really useful since pod IDs change in HA setups, making
the label meaningless.
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you @BerndFarkaDyna for this PR!I appreciate the thorough implementation with tests.

I have some concerns about using owner references for resource tracking:
1/ Garbage collection and cluster scope resources: When referencing cluster scoped resources, owner references become problematic. Since owner references don't contain namespace information for cluster scoped resources, this can trigger immediate garbage collection of these resources since the reference points to non existing resourcse
2/ multi namespace orchestration: kro supports cross namespace orchestration, which doesn't work well with owner references for similar reasons. Owner references struggle with resources that span multiple namespaces

I think kro needs to perform static analysis on the resource graph before deciding whether to use owner references. We should only apply them when:

  • all resources in an RGD are namespace scoped
  • all resources are in the same namespace as the instance
  • no cross namespace references exist

perhaps we could use owner references conditionally based on graph analysis, with labels/annotations tracking as the fallback for more complex cases. Would you be open to refining the implementation with this approach?

or maybe we should aim for tracking via annotations/labels instead for all RGDs/resources? https://argo-cd.readthedocs.io/en/latest/user-guide/resource_tracking/

@BerndFarkaDyna
Copy link
Author

@a-hilaly: I think there is a misunderstanding in how ArgoCD is doing the Resource tracking:

The labels / annotations feature only applies to the "root resources" in the ArgoCD application. If someone deploys any ResourceGraphDefinition Instance, those Objects will get the Labels/Annotations by ArgoCD set.

If this meta-data gets propagated to the corresponding child objects of an RGD Instance ArgoCD will show them as orphans and won't be able to show the parent <-> relations between the RGD Instance and created child objects.

An Example can be seen here where the RGD Instance is creating a service:

With OwnerReference:
image
Without OwnerReference
image
details:
image

There are other projects which have similar problems as described here: argoproj/argo-cd#5082

I'm open to adapting my PR in any way, but adding OnwerReferences is the only way to go if proper ArgoCD support is desired (at the moment), at least in terms of how I understand it.

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