argoproj / argo-helm

ArgoProj Helm Charts
https://argoproj.github.io/argo-helm/
Apache License 2.0
1.64k stars 1.82k forks source link

kustomize rendering/templating of helmchart has issues with Values.server.route.enabled #2717

Open Roguito opened 1 month ago

Roguito commented 1 month ago

Describe the bug

error: Error: template: argo-cd/templates/argocd-server/openshift/route.yaml:1:14: executing "argo-cd/templates/argocd-server/openshift/route.yaml" at <.Values.server.route.enabled>: nil pointer evaluating interface {}.route

Related helm chart

argo-cd

Helm chart version

6.0.6

To Reproduce

$ cat infra/argocd/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ns.yaml
  - http-route.yaml

helmCharts:
  - name: argo-cd
    repo: https://argoproj.github.io/argo-helm
    version: 6.0.6
    releaseName: "argocd"
    namespace: argocd
    valuesFile: values.yaml

$ cat infra/argocd/values.yaml
configs:
  cm:
    create: true
    application.resourceTrackingMethod: "annotation+label"
  cmp:
    create: true
    plugins:
      kustomize-build-with-helm:
        generate:
          command: [ "sh", "-c" ]
          args: [ "kustomize build --enable-helm" ]
  params:
    server:
      insecure:
        true
      route:
        enabled: true

crds:
  install: true
  # -- Keep CRDs on chart uninstall
  keep: false

repoServer:
  extraContainers:
    - name: kustomize-build-with-helm
      command:
        - argocd-cmp-server
      image: '{{ default .Values.global.image.repository .Values.repoServer.image.repository }}:{{ default (include "argo-cd.defaultTag" .) .Values.repoServer.image.tag }}'
      securityContext:
        runAsNonRoot: true
        runAsUser: 999
      volumeMounts:
        - name: plugins
          mountPath: /home/argocd/cmp-server/plugins
        - name: cmp-kustomize-build-with-helm
          mountPath: /home/argocd/cmp-server/config/plugin.yaml
          subPath: kustomize-build-with-helm.yaml
        - mountPath: /tmp
          name: cmp-tmp
  volumes:
    - name: cmp-kustomize-build-with-helm
      configMap:
        name: argocd-cmp-cm
    - name: cmp-tmp
      emptyDir: { }

$ kubectl kustomize --enable-helm infra/argocd
error: Error: template: argo-cd/templates/argocd-server/openshift/route.yaml:1:14: executing "argo-cd/templates/argocd-server/openshift/route.yaml" at <.Values.server.route.enabled>: nil pointer evaluating interface {}.route

Use --debug flag to render out invalid YAML
: unable to run: 'helm template argocd /home/rogue/Project2501/infra/argocd/charts/argo-cd --namespace argocd -f /tmp/kustomize-helm-2822312283/argo-cd-kustomize-values.yaml' with env=[HELM_CONFIG_HOME=/tmp/kustomize-helm-2822312283/helm HELM_CACHE_HOME=/tmp/kustomize-helm-2822312283/helm/.cache HELM_DATA_HOME=/tmp/kustomize-helm-2822312283/helm/.data] (is 'helm' installed?): exit status 1

Expected behavior

Proper templating of this .Values.server.route.enabled

omitting it in value.yaml also produces the above errors. Explicitly providing is also does.

Screenshots

No response

Additional context

No response

Roguito commented 1 month ago

this turned out to be related to the templating, and specifically: charts/argo-cd-6.0.6/argo-cd/templates/argocd-server/openshift/route.yaml and it's,

{{- if .Values.server.route.enabled -}} apiVersion: route.openshift.io/v1 kind: Route metadata: name: {{ template "argo-cd.server.fullname" . }} namespace: {{ .Release.Namespace | quote }} labels: {{- include "argo-cd.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }} {{- with .Values.server.route.annotations }} annotations: {{- range $key, $value := . }} {{ $key }}: {{ $value | quote }} {{- end }} {{- end }} spec: host: {{ .Values.server.route.hostname | quote }} to: kind: Service name: {{ template "argo-cd.server.fullname" . }} weight: 100 port: targetPort: https tls: termination: {{ .Values.server.route.termination_type | quote }} insecureEdgeTerminationPolicy: {{ .Values.server.route.termination_policy | quote }} wildcardPolicy: None {{- end }}

evaluating to false. This would be the case if there were no server.route.enabled defined in the argocd helm chart's values file.

I don't use openshift and have moved on to the API gateway so I just removed the {{- if .Values.server.route.enabled -}} templating.

Roguito commented 1 month ago

apologies... that did not actually fix it. Oh well,back to the drawing board.