Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm translates curly braces {} into normal braces [] when passing value from values.yaml to chart #12980

Open
Preslav93 opened this issue Apr 24, 2024 · 2 comments

Comments

@Preslav93
Copy link

Preslav93 commented Apr 24, 2024

Output of helm version:
version.BuildInfo{Version:"v3.12.3", GitCommit:"3a31588ad33fe3b89af5a2a54ee1d25bfe6eaa5e", GitTreeState:"clean", GoVersion:"go1.20.7"}

Output of kubectl version:
Client Version: v1.28.2 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.28.8

Cloud Provider/Platform (AKS, GKE, Minikube etc.): N/A

I have a helm chart that creates the following kubernetes secret

apiVersion: v1
kind: Secret
metadata:
  name: {{ .Values.kubernetes.appName }}conf
  namespace: {{ .Values.kubernetes.namespace }}
stringData:
  ConnectionStrings__SqlServerDb: Server={{ .Values.app.SqlHost }}; Database={{ .Values.app.SqlDatabase }}; User ID={{ 
  .Values.app.SqlUsername }}; password={{ .Values.secrets.SqlPassword }}; Application Name={{ 
  .Values.kubernetes.appName }}; TrustServerCertificate=true;

the value of the password in enclosed in curly braces e.g {SuperSecretPassword} which at the end gets translated by helm to [SuperSecretPassword] (with normal braces)

I tried escaping and quoting the value in different ways, but nothing seems to work keeping the curly braces in the final value

the only way I managed to get it working was to put the password directly in the secret yaml
password={SuperSecretPassword}

Any ideas how I can make helm ignore the special characters and mainly not translate {} into []?

here some of the escaping and quoting attempts that I did
password={{ .Values.secrets.SqlPassword | quote }} --> "[SuperSecretPassword]"
password={{ toString .Values.secrets.SqlPassword }} --> [SuperSecretPassword]
password="{{ .Values.secrets.SqlPassword }}" --> "[SuperSecretPassword]"
I also tried enclosing the whole ConnectionStrings__SqlServerDb value in ""

And none of the above seem to work

@Preslav93
Copy link
Author

one workaround is to base64 encode the secret when you pass it to the helm kubernetes template and decode it inside the template itself
password={{ .Values.secrets.SqlPassword | b64dec }}

@gjenkins8
Copy link
Contributor

I suspect your values look like?:

secrets:
  SqlPassword: {SuperSecretPassword}

You need to quote SqlPassword: "{SuperSecretPassword}", as curly branches in yaml denote a map. Which is rendered as: password=map[supersecret:<nil>]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants