<p>How can I pass the entire JSON string to a Helm chart value?</p>

<p>I have <code>values.yml</code> where the config value should contain entire JSON with a configuration of an application</p>

<pre><code>...
config: some JSON here
...
</code></pre>

<p>and I need to pass this value to a secret template and then mount it as a volume to a Kubernetes pod.</p>

<pre><code>{{- $env := default "integration" .Values.env}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Release.Name }}-{{ $env }}
type: Opaque
data:
  config.json: {{ .Values.config | b64enc | quote }}
</code></pre>

<p>However the obvious approach of passing single quoted string like <code>'{"redis": "localhost:6379"}'</code> fails because Helm for some reason deletes all double quotes in the string (even if I escape them) so I end up with <code>{redis: localhost:6379}</code> which is not a valid JSON.</p>

<p>Is there any other possibility how to pass configuration to the pod all at once without loading template files with <code>tpl</code> function and making all needed fields accessible via <code>values.yml</code> separately?</p>

Kostrahb
<p>If <code>.Values.config</code> contains json then you can use it in your templated secret with</p>
<pre><code>{{ .Values.config | toJson | b64enc | quote }}
</code></pre>
<p>It may seem strange to use <code>toJson</code> to convert JSON to JSON but helm doesn't natively treat it as JSON until you tell it to. See the SO question <a href="https://stackoverflow.com/questions/52930405/how-do-i-use-json-variables-in-a-yaml-file-helm">How do I use json variables in a yaml file (Helm)</a> for an example of doing this.</p>
