1

In one of my Deployment resource template I have something like this (the problem will be the same if using simple yaml resource file) :

...
spec:
  containers:
    - name: {{ .Release.Name }}
      image: {{ template "common.image" . }}
      env:
        - name: EMAIL_PASSWORD
          valueFrom:
            secretKeyRef:
             name: {{ include "common.fullname" . }}
             key: email-password
....

When I run a helm template command, this template generates the following yaml output :

...
spec:
  containers:
    - env:
        - name: BASIC_AUTH_USER
        - value: @myPa$$word
...

As you can see, the password starts with a special character "@". Because of that, it generates the following error when I run a helm install or template :

error: error parsing deployment.yaml: error converting YAML to JSON: yaml: line 62: found character that cannot start any token

If I change the password and remove the "@" everything works fine. But I'd like to be sure I will not encounter this error and for that, I need to be able to quote the generated value :

...
spec:
  containers:
    - env:
        - name: BASIC_AUTH_USER
        - value: "@myPa$$word"
...

But I didn't find any way to do it. I could add a quote in the secret value but it's not really clean: how to know if the quotes are part of the password or not. If anyone has a solution, I'm very interested. I didn't find anything while Googling.

Nicolas Forney
  • 868
  • 2
  • 13
  • 21
  • Helm won't expand that `secretKeyRef:` block; `helm template` doesn't even contact the Kubernetes cluster. Can you double-check that you've quoted the right part of your YAML file (for the `BASIC_AUTH_USER` variable)? – David Maze Sep 06 '21 at 11:11
  • Try single quotes. See [Do I need quotes for strings in YAML](https://stackoverflow.com/a/22235064/11934850) – Sascha Doerdelmann Aug 01 '22 at 10:50

0 Answers0