kuberneteskubernetes-helmargocd

Prevent ArgoCD from syncing a single ressource


I have an ArgoCD App which is generating symbols

apiVersion: v1
kind: Secret
metadata:
  labels:
    {{- include "myapp.labels" . | nindent 4 }}
  annotations:
    helm.sh/hook: pre-install,post-delete
  name: {{ include "myapp.fullname" . }}
type: Opaque
data:
  {{- if .Values.password }}
  password: {{ .Values.password | b64enc | quote }}
  {{- else }}
  password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}

A second service is adding additional values to the secrets later. I don't want this secrets in my chart

Now when something is changed on the app, the secrets are recreated.

How can i change this behaviour in ArgoCD?


Solution

  • Add annotation to that particular object and it should work

    apiVersion: v1
    kind: Secret
    metadata:
      labels:
        {{- include "myapp.labels" . | nindent 4 }}
      annotations:
        helm.sh/hook: pre-install,post-delete
        argocd.argoproj.io/sync-options: Prune=false
    

    Some Sync Options can defined as annotations in a specific resource. Most of the Sync Options are configured in the Application resource spec.syncPolicy.syncOptions attribute. Multiple Sync Options which are configured with the argocd.argoproj.io/sync-options annotation can be concatenated with a , in the annotation value; white spaces will be trimmed.

    no-prune-resources

    Or if you don’t want to apply auto sync on this object then you can try ApplyOutOfSyncOnly=false

    selective-sync