argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.59k stars 5.36k forks source link

Allow to use helm.valuesObject and kustomize at the same time. Error: Manifest generation error (cached): multiple application sources defined: Kustomize, Helm #17461

Open gomin1d opened 6 months ago

gomin1d commented 6 months ago

Summary

It is not possible to use helm.valuesObject and kustomize at the same time. If I try to do this, I get the error:

Failed to load target state: failed to generate manifest for source 1 of 2: rpc error: code = Unknown desc = Manifest generation error (cached): multiple application sources defined: Kustomize,Helm

Motivation

Here is my living example. I install helm chart mailu. I configured it via valuesObject. And also I want to configure tolerations and nodeSelector via kustomize.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: mailu
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  sources:
    - repoURL: https://mailu.github.io/helm-charts/
      targetRevision: 1.5.0
      chart: mailu
      kustomize:
        patches:
          - target:
              kind: Deployment
            patch: |-
              - op: add
                path: /spec/template/spec
                value: 
                  tolerations:
                   - key: "host"
                     operator: "Equal"
                     value: "critical"
                     effect: "NoSchedule"
                  nodeSelector:
                   'kubernetes.io/hostname': 'dev.mineland.local'
      helm:
        valuesObject:
          oletools:
            enabled: false
          subnet: 10.233.64.0/18
          front:
            hostPort:
              enabled: false
          domain: mail.gomin1d.top
          hostnames:
            - mail.gomin1d.top
          timezone: Europe/Kyiv
          ingress:
            ingressClassName: nginx
            annotations:
              cert-manager.io/cluster-issuer: "letsencrypt-prod"
          webmail:
            enabled: false
          logLevel: INFO
          limits:
            authRatelimit:
              ip: 100/minute;3600/hour
              user: 100/day
            messageSizeLimitInMegabytes: 200
          persistence:
            existingClaim: mailu-pvc
          clamav:
            enabled: false
          redis:
            enabled: false
    - repoURL: git@gitlab.com:gomin1ds/gomin1ds-argocd.git
      path: 'mailu'
      targetRevision: HEAD
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: gomin1ds
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Proposal

Support simultaneous use of helm.valuesObject and kustomize at the same time. Or add the ability to change helm variables in kustomize.

MartinLoeper commented 3 months ago

Is there currently a workaround to this?

crenshaw-dev commented 3 months ago

I think my preference would be that we add support for kustomization.yaml's helmCharts field by adding it to spec.source.kustomize. Then users can take advantage of the spec.source.kustomize.helmCharts[].valuesInline field.

gomin1d commented 3 months ago

Is there currently a workaround to this?

@MartinLoeper yes, my solution: https://github.com/Mailu/helm-charts/issues/341#issuecomment-2089030963