argoproj / argo-cd

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

Custom values ignored if values.yaml not present on multi source apps #18090

Open fdziarmagowski opened 1 week ago

fdziarmagowski commented 1 week ago

Checklist:

Describe the bug Can't add a new application when multiple sources are defined, <path>/values.yaml is not present and custom values are defined on the command line.

To Reproduce Try to create a multi source based app and custom values file with the configuration below

Expected behavior I would expect, that passing --values <custom file>.yaml should be sufficient to define a new application.

Screenshots

Application repo:

.
└── apps
    ├── Chart.yaml
    ├── templates
    │   └── cert-manager.yaml
    └── values-test.yaml

cert-manager.yaml:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: cert-manager
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: base-infra
  sources:
    - chart: cert-manager
      repoURL: https://charts.jetstack.io
      targetRevision: v1.14.5
      helm:
        valueFiles:
          - $values/charts/cert-manager/cert-manager-values.yaml
    - repoURL: '{{ .Values.spec.source.repoURL }}'
      targetRevision: '{{ .Values.spec.source.targetRevision }}'
      ref: values
  destination:
    server: https://kubernetes.default.svc
    namespace: cert-manager
  syncPolicy:
    automated:
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

apps/values-test.yaml:

---
spec:
  source:
    repoURL: <values repo URL>
    targetRevision: HEAD

"values" repo:

.
└── charts
    └── cert-manager
        └── cert-manager-values.yaml

charts/cert-manager/cert-manager-values.yaml:

---
installCRDs: true
prometheus:
  enabled: true

Version

argocd: v2.10.7+b060053
  BuildDate: 2024-04-15T09:05:25Z
  GitCommit: b060053b099b4c81c1e635839a309c9c8c1863e9
  GitTreeState: clean
  GoVersion: go1.21.9
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.10.7+b060053
  BuildDate: 2024-04-15T09:05:25Z
  GitCommit: b060053b099b4c81c1e635839a309c9c8c1863e9
  GitTreeState: clean
  GoVersion: go1.21.9
  Compiler: gc
  Platform: linux/amd64
  Kustomize Version: could not get kustomize version: exec: "kustomize": executable file not found in $PATH
  Helm Version: v3.12.0
  Kubectl Version: v0.26.11
  Jsonnet Version: v0.20.0

Logs

argocd app create apps --repo <my repo> --path apps --dest-server https://kubernetes.default.svc --dest-namespace argocd --values values-test.yaml
FATA[0000] rpc error: code = InvalidArgument desc = application spec for apps is invalid: InvalidSpecError: Unable to generate manifests in apps: rpc error: code = Unknown desc = Manifest genera
tion error (cached): `helm template . --name-template apps --namespace argocd --kube-version 1.29 --values <path to cached source>/apps/values-test.yaml <api versions removed> --include-crds` fa
iled exit status 1: Error: template: applications/templates/cert-manager.yaml:19:25: executing "applications/templates/cert-manager.yaml" at <.Values.spec.source.repoURL>: can't evaluate field r
epoURL in type interface {}

Workaround

Create an empty values.yaml file in the "application" repository:

.
└── apps
    ├── Chart.yaml
    ├── templates
    │   └── cert-manager.yaml
    ├── values-test.yaml
    └── values.yaml   # THIS