How to pass entire JSON string to Helm chart value?

If .Values.config contains json then you can use it in your templated secret with

{{ .Values.config | toJson | b64enc | quote }}

It may seem strange to use toJson to convert JSON to JSON but helm doesn't natively treat it as JSON until you tell it to. See the SO question How do I use json variables in a yaml file (Helm) for an example of doing this.


Here is another suggestion if you want to avoid encoding :

env:
  - name: MYCONFIG
  value: {{ .Files.Get "config.json" | toPrettyJson }}

According to the helm docs, helm uses template functions such as toPrettyJson which are supplied by the built-in Go text/template package and the Sprig template function library.


when passing something to --set or --set-string and you don't want helm to interpret it you want to escape every single of=

{
[
,
.
]
}

with backslash. Remember about your shell that might interpret \ so sometimes you might want to \ or use value in single quotas instead. Something like this works for me in bash:

--set airflow.config.AIRFLOW__SECRETS__BACKEND_KWARGS='\{\\\"variables_prefix\\\": \\\"/here-is-my-prefix/'${bamboo_deploy_environment}'/airflow/variables\\\"\, \\\"connections_prefix\\\": \\\"/here-is-my-prefix/'${bamboo_deploy_environment}'/airflow/connections\\\"\}'