argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

feat: allow setting custom parents via metadata (Alpha) #5082

Open jake-ciolek opened this issue 1 year ago • 10 comments

I took a stab at #5082 and took a slightly different approach. Instead of users specifying the parent/child relationship in config, we could allow setting it in the metadata.

This change allows users to define a parent/child relationship for resources where this cannot be inferred from the ownerRef values. The child resource might be a Cluster-scoped CR and the parent might be a namespaced CRD.

The API is straightforward and boils down to setting annotations that define the parent, i.e:

argocd.argoproj.io/parentName: custom-api.example.com/v1alpha1
argocd.argoproj.io/parentKind: Database
argocd.argoproj.io/parentApiVersion: my-claimed-database
argocd.argoproj.io/parentNamespace: parent-namespace

If a custom parent is defined, we take it over the ownerRef values.

This allows us to display a more ordered resource tree. Some concrete examples include Istio Operator and Crossplane resources (relationship between Claims and Composite Resources).

In the screenshots, you can see that it brings order to the resource tree of Istio Operator and draws the relationship between Crossplane Claim and Crossplane XR.

This is an early implementation and I would appreciate feedback on this approach and pointers on how to make it better. Thanks!

Updates #5082

Screenshot 2024-11-22 at 14 34 18 Screenshot 2024-11-22 at 14 34 31

Checklist:

  • [x] Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • [x] The title of the PR states what changed and the related issues number (used for the release note).
  • [x] The title of the PR conforms to the Toolchain Guide
  • [ ] I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • [x] I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • [x] Does this PR require documentation updates?
  • [ ] I've updated documentation as required by this PR.
  • [x] I have signed off all my commits as required by DCO
  • [x] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • [x] My build is green (troubleshooting builds).
  • [x] My new feature complies with the feature status guidelines.
  • [x] I have added a brief description of why this PR is necessary and/or what this PR solves.
  • [ ] Optional. My organization is added to USERS.md.
  • [ ] Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

jake-ciolek avatar Nov 22 '24 14:11 jake-ciolek

:exclamation: Preview Environment undeploy from Bunnyshell failed

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • :rocket: /bns:deploy to redeploy the environment
  • :x: /bns:delete to try again to remove the environment

bunnyshell[bot] avatar Nov 22 '24 14:11 bunnyshell[bot]

Do you have a gitops-engine PR to update the tree construction logic?

andrii-korotkov-verkada avatar Nov 23 '24 02:11 andrii-korotkov-verkada

Codecov Report

Attention: Patch coverage is 80.00000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 55.11%. Comparing base (32cc663) to head (1e054d0). Report is 28 commits behind head on master.

Files with missing lines Patch % Lines
controller/cache/cache.go 80.00% 8 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20908      +/-   ##
==========================================
+ Coverage   55.04%   55.11%   +0.07%     
==========================================
  Files         324      324              
  Lines       55421    55507      +86     
==========================================
+ Hits        30504    30595      +91     
+ Misses      22303    22295       -8     
- Partials     2614     2617       +3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 02 '24 11:12 codecov[bot]

Thanks @reggie-k . I changed the annotations to parent* and updated the docs.

jake-ciolek avatar Dec 02 '24 11:12 jake-ciolek

@andrii-korotkov-verkada

I’ve taken another look at the gitops-engine code and would welcome your input on what exactly you had in mind. It appears this feature may be specific to Argo CD’s UI layer, given that gitops-engine’s structure differs significantly: for example, it lacks the asResource function, and (*clustercache).IterateHierarchyV2 behaves differently. I’ve reached out to you on Slack—perhaps we can work together on adapting these changes for gitops-engine, if that’s something you’re interested in. Thanks!

jake-ciolek avatar Dec 16 '24 12:12 jake-ciolek

@jake-ciolek @andrii-korotkov-verkada is there any intention to move this forward?

Aym3nTN avatar Jul 21 '25 09:07 Aym3nTN

I was searching for the solution of controlling parent-child hierarchy, this feature would helped a lot

jiri-soukal-pfx avatar Sep 17 '25 07:09 jiri-soukal-pfx

I'd LOVE to see this! can this feature be prioritized?

wmcnamee-coreweave avatar Nov 25 '25 19:11 wmcnamee-coreweave

@nitishfy @wmcnamee-coreweave @jiri-soukal-pfx @Aym3nTN

I'll pick it up soon again. Preliminary time - next week.

jake-ciolek avatar Dec 03 '25 10:12 jake-ciolek

Great initiative!

Can you change the annotation names to kebab-case to adhere to https://kubernetes.io/docs/concepts/overview/working-with-objects/names/?

argocd.argoproj.io/parent-name
argocd.argoproj.io/parent-api-version
argocd.argoproj.io/parent-kind
argocd.argoproj.io/parent-namespace

illrill avatar Dec 03 '25 16:12 illrill