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

prune option doesn't play nice with CiliumIdentity resource

Open michalschott opened this issue 1 year ago • 3 comments

Hey,

I'm running on EKS with Cilium as CNI, deploying apps with kustomize with prune option enabled.

Given my kustomization looks like this:

kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: secrets-store-csi-driver
resources:
- aws-provider-installer.yaml
- namespace.yaml
- secrets-store-csi-driver.yaml

namespace.yaml:

apiVersion: v1
kind: Namespace
metadata:
  name: secrets-store-csi-driver
  labels:
    goldilocks.fairwinds.com/enabled: "true"
  annotations:
    downscaler/exclude: "true"

Cilium automatically creates CiliumIdentity object, which ArgoCD obviously catch up and here is where story begins:

  • app (especially CiliumIdentity) is constantly marked as Out-Of-Sync Zrzut ekranu 2022-08-25 o 17 32 10
  • resource is being constantly removed by Argo
  • Cilium recreates the object

How can I prevent this behaviour without turning off prune option?

michalschott avatar Aug 25 '22 15:08 michalschott

@michalschott You can add an annotation to the specific object CiliumIdentity, preventing it from pruning. Is this option work for you?

metadata:
  annotations:
    argocd.argoproj.io/sync-options: Prune=false

https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#no-prune-resources

ashutosh16 avatar Aug 26 '22 05:08 ashutosh16

@ashutosh16 not really, as these objects are not included in kustomization and are created by cilium itself

michalschott avatar Aug 26 '22 10:08 michalschott

DigitalOcean Kubernetes are using cilium by default, i have the same issue

debu99 avatar Sep 12 '22 14:09 debu99

@debu99

Apparently this fixed the issue for me:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
data:
  resource.exclusions: |
    - apiGroups:
      - cilium.io
      kinds:
      - CiliumIdentity
      clusters:
      - "*"

Should be included as a default IMHO.

michalschott avatar Sep 16 '22 13:09 michalschott

Yes. This is documented here: https://docs.cilium.io/en/stable/configuration/argocd-issues/#argo-cd-deletes-customresourcedefinitions

Still, I don't understand why ArgoCD catches those resources. Maybe they copy the labels and annotations from the pods. Could this be a bug in how ArgoCD prunes?

sathieu avatar Oct 05 '22 18:10 sathieu