<p>At present I am creating a configmap from the file config.json by executing:</p>

<pre><code>kubectl create configmap jksconfig --from-file=config.json
</code></pre>

<p>I would want the ConfigMap to be <em>created</em> as part of the deployment and tried to do this:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: jksconfig
data:
  config.json: |-
    {{ .Files.Get "config.json" | indent 4 }}
</code></pre>

<p>But doesn't seem to work. What should be going into configmap.yaml so that the same configmap is created? </p>

<p>---UPDATE---</p>

<p>when I do a helm install dry run:</p>

<pre><code># Source: mychartv2/templates/jks-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: jksconfig
data:
  config.json: |
</code></pre>

<p><strong>Note</strong>: I am using minikube as my kubernetes cluster</p>

Chillax
<p>Your <code>config.json</code> file should be inside your <strong>mychart/</strong> directory, not inside  <strong>mychart/templates</strong></p>
<p><a href="https://helm.sh/docs/chart_template_guide/accessing_files/#basic-example" rel="noreferrer">Chart Template Guide</a></p>
<p><strong>configmap.yaml</strong></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  config.json: |-
{{ .Files.Get &quot;config.json&quot; | indent 4}}
</code></pre>
<p><strong>config.json</strong></p>
<pre><code>{
    &quot;val&quot;: &quot;key&quot;
}
</code></pre>
<p><code>helm install --dry-run --debug mychart</code></p>
<pre><code>[debug] Created tunnel using local port: '52091'     
                                                     
[debug] SERVER: &quot;127.0.0.1:52091&quot;                    
                                                     
...           
                                                     
NAME:   dining-saola                                 
REVISION: 1                                          
RELEASED: Fri Nov 23 15:06:17 2018                   
CHART: mychart-0.1.0                                 
USER-SUPPLIED VALUES:                                
{}                                                   
                                                     
...
                                                     
---                                                  
# Source: mychart/templates/configmap.yaml           
apiVersion: v1                                       
kind: ConfigMap                                      
metadata:                                            
  name: dining-saola-configmap                       
data:                                                
  config.json: |-                                    
    {                                                
        &quot;val&quot;: &quot;key&quot;                                 
    }     
</code></pre>
<p>EDIT:</p>
<blockquote>
<p>But I want it the values in the config.json file to be taken from values.yaml. Is that possible?</p>
</blockquote>
<p><strong>configmap.yaml</strong></p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  config.json: |-
    {
{{- range $key, $val := .Values.json }}
{{ $key | quote | indent 6}}: {{ $val | quote }}
{{- end}}
    }
</code></pre>
<p><strong>values.yaml</strong></p>
<pre><code>json:
  key1: val1
  key2: val2
  key3: val3
</code></pre>
<p><code>helm install --dry-run --debug mychart</code></p>
<pre><code># Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: mangy-hare-configmap
data:
  config.json: |-
    {
      &quot;key1&quot;: &quot;val1&quot;
      &quot;key2&quot;: &quot;val2&quot;
      &quot;key3&quot;: &quot;val3&quot;
    }
</code></pre>
