<p>We are going to write Helm chart and providing configuration file using configmap. </p>

<p>For some reasons our app is using JSON format configuration file. Currently we provide configuration file in Helm chart's values.yaml like this.</p>

<pre><code>conffiles:
  app_conf.json:
    ...(content in YAML)...
</code></pre>

<p>And to make it easy to modify, in values.yaml we use YAML format and in configmap's template we did conversion using "toJson",</p>

<pre><code>data:
{{- range $key, $value := .Values.conffiles }}
  {{ $key }}: |      
{{ toJson $value | default "{}" | indent 4 }}
{{- end -}}
{{- end -}}
</code></pre>

<p>So in values.yaml it's YAML, and in configmap it will be JSON, then in container it will be stored into JSON file.</p>

<p>Our question is,</p>

<ul>
<li>Is there a way to convert YAML to JSON when saving files into container? That  is, we hope those configuration content could be 1) YAML in values.yaml 2) YAML in configmap 3) JSON file in container </li>
</ul>

<p>Thank in advance.</p>

Lijing Zhang
<p>I don't think there is anything out of the box but you do have options, depending upon your motivation.</p>

<p>Your app is looking for json and the configmap is mounted for your app to read that json. Your helm deployment isn't going to modify the container itself. But you could change your app to read yaml instead of json.</p>

<p>If you want to be able to easily see the yaml and json versions you could create two configmaps - one containing yaml and one with json. </p>

<p>Or if you're just looking to be able to see what the yaml was that was used to create the configmap then you could use <a href="https://github.com/helm/helm/blob/master/docs/helm/helm_get_values.md" rel="nofollow noreferrer"><code>helm get values &lt;release_name&gt;</code></a> to look at the values that were used to create that release (which will include the content of the <code>conffiles</code> entry).</p>
