<p>The plan is to move my dockerized application to Kubernetes.</p>

<p>The docker container uses couple of files - which I used to mount on the docker volumes by specifying in the docker-compose file:</p>

<pre><code>volumes:
      - ./license.dat:/etc/sys0/license.dat
      - ./config.json:/etc/sys0/config.json
</code></pre>

<p>The config file would be different for different environments, and the license file would be the same across.</p>

<p>How do I define this in a helm template file (yaml) so that it is available for the running application?</p>

<p>What is generally the best practise for this? Is it also possible to define the configuration values in values.yaml and the config.json file could get it?</p>

Chillax
<p>Since you are dealing with json a good example to follow might be the <a href="https://github.com/helm/charts/tree/cbd5e811a44c7bac6226b019f1d1810ef5ee45fa/stable/centrifugo" rel="noreferrer">official stable/centrifugo chart</a>. It defines a ConfigMap that contains a config.json file:</p>

<pre><code>data:
  config.json: |-
{{ toJson .Values.config| indent 4 }}
</code></pre>

<p>So it takes a <code>config</code> section from the values.yaml and transforms it to json using the toJson function. The config can be whatever you want define in that yaml - the chart has:</p>

<pre><code>config:
  web: true
  namespaces:
  - name: public
    anonymous: true
    publish: true
...
</code></pre>

<p>In the deployment.yaml it <a href="https://github.com/helm/charts/blob/cbd5e811a44c7bac6226b019f1d1810ef5ee45fa/stable/centrifugo/templates/deployment.yaml#L67" rel="noreferrer">creates a volume from the configmap</a>:</p>

<pre><code>      volumes:
      - name: {{ template "centrifugo.fullname" . }}-config
        configMap:
          name: {{ template "centrifugo.fullname" . }}-config
</code></pre>

<p>Note that <code>{{ template "centrifugo.fullname" . }}-config</code> <a href="https://github.com/helm/charts/blob/cbd5e811a44c7bac6226b019f1d1810ef5ee45fa/stable/centrifugo/templates/configmap.yaml#L4" rel="noreferrer">matches the name of the ConfigMap</a>.</p>

<p>And <a href="https://github.com/helm/charts/blob/cbd5e811a44c7bac6226b019f1d1810ef5ee45fa/stable/centrifugo/templates/deployment.yaml#L50" rel="noreferrer">mounts it into the deployment's pod/s</a>:</p>

<pre><code>        volumeMounts:
        - name: "{{ template "centrifugo.fullname" . }}-config"
          mountPath: "/centrifugo"
          readOnly: true
</code></pre>

<p>This approach would let you populate the json config file from the values.yaml so that you can set different values for different environments by supplying custom values file per env to override the default one in the chart. </p>

<p>To handle the license.dat you can add an extra entry to the ConfigMap to define an additional file but with static content embedded. Since that is a license you may want to switch the ConfigMap to a Secret instead, which is a simple change of replacing the word ConfigMap for Secret in the definitions. You could try it with ConfigMap first though.</p>
