cicdargocd

How to set Helm Argument —create-namespace in ArgoCD Applications Definition


I have try to add cert-Manager via Helm through ArgoCD applicaton Definition. I set the Namenspace value for the Helm chart. And if i sync the following definition i get an error because the namespace cert-manager dose not exists.

    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: cert-manager
      namespace: argocd
    spec:
      project: default
      source:
        repoURL: 'https://charts.jetstack.io'
        targetRevision: v1.15.1
        chart: cert-manager
        helm:
          parameters:
            - name: crds.enabled
              value: 'true'
            - name: startupapicheck.timeout
              value: 5m
            - name: namespace
              value: cert-manager
      destination:
        server: 'https://kubernetes.default.svc'
      syncPolicy:
        syncOptions:
          - CreateNamespace=true

Does anyone know how I can pass the Helm Argument create-namespace to do this?

Many greetings and thanks


Solution

  • The namespace you're trying to create needs to be in spec.destination.namespace in addition to whatever the helm chart is expecting.

    https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#create-namespace

    "The example above shows how an Argo CD Application can be configured so it will create the namespace specified in spec.destination.namespace if it doesn't exist already. ..."

        apiVersion: argoproj.io/v1alpha1
        kind: Application
        metadata:
          name: cert-manager
          namespace: argocd
        spec:
          project: default
          source:
            repoURL: 'https://charts.jetstack.io'
            targetRevision: v1.15.1
            chart: cert-manager
            helm:
              parameters:
                - name: crds.enabled
                  value: 'true'
                - name: startupapicheck.timeout
                  value: 5m
                - name: namespace
                  value: cert-manager
          destination:
            server: 'https://kubernetes.default.svc'
            namespace: cert-manager
          syncPolicy:
            syncOptions:
              - CreateNamespace=true