Output of helm version: v3.13.3
Output of kubectl version: 1.27.3
Cloud Provider/Platform (AKS, GKE, Minikube etc.): self-hosted
I utilize ArgoCD with an "app of apps" setup. For this purpose, I deploy my ApplicationSet using a Helm chart. The template appears as follows:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
spec:
generators:
- list:
elements:
- cluster: dev-cluster
url: https://1.2.3.4
- cluster: prod-cluster
url: https://2.4.6.8
- cluster: preprod-cluster
url: https://9.8.7.6
template:
metadata:
name: '{{cluster}}-guestbook'
spec:
project: default
source:
repoURL: https://github.com/argoproj/argo-cd.git
targetRevision: HEAD
path: "."
destination:
server: '{{url}}'
namespace: guestbook
However, upon running helm template HELM_REPO, I encounter this error:
Error: parse error at (argocd-helm/templates/not-working.yaml:17): function "cluster" not defined
I discovered that deploying a YAML file with {{ }} as plain text causes issues because the Golang code attempts to evaluate its content.
how to overcome this problem:
I realized that both Helm and Argo utilities use Go templating. We actually want ArgoCD to interpret the {{cluster}} and not Helm.
To resolve this issue, we can employ Go templating within Helm by using:
'{{ printf "{{cluster}}" }}'. This "tricks" Helm into ignoring the initial curly braces and allows ArgoCD to interpret them correctly.
The revised ArgoCD ApplicationSet appears as follows:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: guestbook
spec:
generators:
- list:
elements:
- cluster: dev-cluster
url: https://1.2.3.4
- cluster: prod-cluster
url: https://2.4.6.8
- cluster: preprod-cluster
url: https://9.8.7.6
template:
metadata:
name: '{{ printf "{{cluster}}" }}-guestbook'
spec:
project: default
source:
repoURL: https://github.com/argoproj/argo-cd.git
targetRevision: HEAD
path: "."
destination:
server: '{{ printf "{{url}}" }}'
namespace: guestbook
Output of
helm version: v3.13.3Output of
kubectl version: 1.27.3Cloud Provider/Platform (AKS, GKE, Minikube etc.): self-hosted
I utilize ArgoCD with an "app of apps" setup. For this purpose, I deploy my ApplicationSet using a Helm chart. The template appears as follows:
However, upon running
helm template HELM_REPO, I encounter this error:Error: parse error at (argocd-helm/templates/not-working.yaml:17): function "cluster" not definedI discovered that deploying a YAML file with
{{ }}as plain text causes issues because the Golang code attempts to evaluate its content.how to overcome this problem:
I realized that both Helm and Argo utilities use Go templating. We actually want ArgoCD to interpret the
{{cluster}}and not Helm.To resolve this issue, we can employ Go templating within Helm by using:
'{{ printf "{{cluster}}" }}'. This "tricks" Helm into ignoring the initial curly braces and allows ArgoCD to interpret them correctly.The revised ArgoCD ApplicationSet appears as follows: