crossplane / crossplane

The Cloud Native Control Plane
https://crossplane.io
Apache License 2.0
9.37k stars 945 forks source link

crossplane with argocd not working correctly #5810

Closed pablofilgueira91 closed 4 weeks ago

pablofilgueira91 commented 3 months ago

hello, I followed this documentation but it didn’t work for me URL: https://docs.crossplane.io/latest/guides/crossplane-with-argo-cd/ I am trying to use crossplane with argocd, but it does not correctly show me the relationship between the claim (azresourcegroup) and the XR (xazresourcegroup). If it correctly shows the relationship between the MR (resourcegroup) and the XR (xazresourcegroup) I suppose it is because the XR does not have ownerreference to the claim since it uses claimref and argocd should not understand it And the MR does have an owner reference to the XR This is how I graph it in argocd image and this is how I should graph it image

this is de claim

apiVersion: azure.upbound.io/v1alpha1
kind: azresourcegroup
metadata:
  annotations:
    argocd.argoproj.io/tracking-id: pablo-test:azure.upbound.io/azresourcegroup:pablo/rg-testpablo-cnt
  name: rg-testpablo-cnt
  namespace: pablo
spec:
  compositeDeletePolicy: Background
  compositionRef:
    name: xazresourcegroups
  compositionRevisionRef:
    name: xazresourcegroups-cd8c899
  compositionUpdatePolicy: Automatic
  resourceRef:
    apiVersion: azure.upbound.io/v1alpha1
    kind: Xazresourcegroup
    name: rg-testpablo-cnt-fb6wx
  servicename: testpablo-cnt

the XR

apiVersion: azure.upbound.io/v1alpha1
kind: Xazresourcegroup
metadata:
  annotations:
    argocd.argoproj.io/tracking-id: pablo-test:azure.upbound.io/azresourcegroup:pablo/rg-testpablo-cnt
  labels:
    crossplane.io/claim-name: rg-testpablo-cnt
    crossplane.io/claim-namespace: pablo
    crossplane.io/composite: rg-testpablo-cnt-fb6wx
  name: rg-testpablo-cnt-fb6wx
spec:
  claimRef:
    apiVersion: azure.upbound.io/v1alpha1
    kind: azresourcegroup
    name: rg-testpablo-cnt
    namespace: pablo
  compositionRef:
    name: xazresourcegroups
  compositionRevisionRef:
    name: xazresourcegroups-cd8c899
  compositionUpdatePolicy: Automatic
  resourceRefs:
  - apiVersion: azure.upbound.io/v1beta1
    kind: ResourceGroup
    name: rg-prod-testpablo-cnt
  servicename: testpablo-cnt
  writeConnectionSecretToRef:
    name: aab9545b-c514-45e1-a32f-81dc7e024f8e
    namespace: crossplane-system

and the MR

apiVersion: azure.upbound.io/v1beta1
kind: ResourceGroup
metadata:
  annotations:
    crossplane.io/composition-resource-name: rg
    crossplane.io/external-create-pending: "2024-07-02T17:32:12Z"
    crossplane.io/external-create-succeeded: "2024-07-02T17:32:12Z"
    crossplane.io/external-name: rg-prod-testpablo-cnt
  creationTimestamp: "2024-07-02T17:32:12Z"
  finalizers:
  - finalizer.managedresource.crossplane.io
  generateName: rg-testpablo-cnt-fb6wx-
  generation: 2
  labels:
    crossplane.io/claim-name: rg-testpablo-cnt
    crossplane.io/claim-namespace: pablo
    crossplane.io/composite: rg-testpablo-cnt-fb6wx
  name: rg-prod-testpablo-cnt
  ownerReferences:
  - apiVersion: azure.upbound.io/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Xazresourcegroup
    name: rg-testpablo-cnt-fb6wx
    uid: aab9545b-c514-45e1-a32f-81dc7e024f8e
  resourceVersion: "450102246"
  uid: 73e6bca4-4e02-4e3c-8b45-cd5bda6c5b97
spec:
  deletionPolicy: Delete
  forProvider:
    location: East US 2
    tags:
      feature: testpablo-cnt
      provider: crossplane
  initProvider: {}
  managementPolicies:
  - '*'
  providerConfigRef:
    name: default

argocd version: 5.50.1 crossplane version: 1.15.2

duizabojul commented 3 months ago

A cluster scoped resource cannot have a namespace scoped resource as owner. Even if you try to add it to ownerreferences, argo will ignore it.

The only way to display XR created by a claim in argo UI is to use annotation (see https://argo-cd.readthedocs.io/en/stable/user-guide/resource_tracking/#non-self-referencing-annotations)

pablofilgueira91 commented 3 months ago

A cluster scoped resource cannot have a namespace scoped resource as owner. Even if you try to add it to ownerreferences, argo will ignore it.

The only way to display XR created by a claim in argo UI is to use annotation (see https://argo-cd.readthedocs.io/en/stable/user-guide/resource_tracking/#non-self-referencing-annotations)

Yes, of course, I know. I am using the application.resourceTrackingMethod annotation but argocd shows it this way. Is there a way for Argo to show that the XR and the claim are linked? It would be a way for argocd to recognize the claimref but I don't know if that will be possible. image

duizabojul commented 2 months ago

It is indeed not possible to customize how argo "link" resources, it can only use ownerreferences to create the linking in UI, so in this case it is impossible to link a namespaced claim to a cluster scoped XR.