argoproj / gitops-engine

Democratizing GitOps
https://pkg.go.dev/github.com/argoproj/gitops-engine?tab=subdirectories
Apache License 2.0
1.7k stars 264 forks source link

Annotation not working argocd.argoproj.io/sync-options: Force=true,Replace=true #578

Open ybucci opened 6 months ago

ybucci commented 6 months ago

I Using the latest version ArgoCD 2.11, but the annotation not working

error when replacing "/dev/shm/2809239019": EC2NodeClass.karpenter.k8s.aws "aws-node-template" is invalid: spec.role: Invalid value: "string": immutable field changed

apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
metadata:
  annotations:
    argocd.argoproj.io/sync-options: Force=true,Replace=true
  name: aws-node-template
spec:
  amiFamily: Bottlerocket
  blockDeviceMappings:
  - deviceName: /dev/xvda
    ebs:
      deleteOnTermination: true
      encrypted: true
      volumeSize: 4Gi
      volumeType: gp3
  - deviceName: /dev/xvdb
    ebs:
      deleteOnTermination: true
      encrypted: true
      volumeSize: 120Gi
      volumeType: gp3
  metadataOptions:
    httpEndpoint: enabled
    httpProtocolIPv6: disabled
    httpPutResponseHopLimit: 2
    httpTokens: required
  role: XXXXXXXX
  securityGroupSelectorTerms:
  - tags:
      karpenter.sh/discovery: XXXXXXXX
  subnetSelectorTerms:
  - tags:
      Name: '*private*'
  tags:
    karpenter.sh/discovery: XXXXXXXX
{{- if and .Values.karpenterTemplates .Values.karpenterTemplates.enable -}}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: karpenter-templates
  namespace: {{ .Values.argoNamespace | default "argocd" }}
  annotations:
    argocd.argoproj.io/sync-wave: "{{ .Values.karpenterTemplates.syncWave | default '0' }}"
  labels:
    app: "karpenter-templates"
    env: "{{ .Values.environment }}"
    clusterName: "{{ .Values.clusterName }}"
spec:
  project: {{ .Values.argoProject | default "default" }}
  source:
    repoURL: {{ .Values.repoUrl }}
    path: 05-helm/karpenter-templates
    targetRevision: {{ .Values.targetRevision }}
    helm:
      values: |-
{{- toYaml .Values.karpenterTemplates | nindent 8 }}
  destination:
    server: {{ .Values.destinationServer | default "https://kubernetes.default.svc" }}
    namespace: {{ .Values.karpenterTemplates.namespace }}
  syncPolicy:
    automated:
      prune: true
      selfHeal: true 
    syncOptions:
#      - Replace=true
      - CreateNamespace=true
      # - ApplyOutOfSyncOnly=true
      # - ServerSideApply=true
      # - Force=true
    retry:
      limit: 10
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 1m
{{- end -}}