<p>I'm trying to template variables from a map inside the values.yaml into my final Kubernetes ConfigMap YAML.</p>

<p>I've read through <a href="https://github.com/helm/helm/issues/2492" rel="noreferrer">https://github.com/helm/helm/issues/2492</a> and <a href="https://helm.sh/docs/chart_template_guide/" rel="noreferrer">https://helm.sh/docs/chart_template_guide/</a> but can't seem to find an answer.</p>

<p>For some context, this is roughly what I'm trying to do:</p>

<p><strong>values.yaml</strong></p>

<pre><code>config:
  key1: value
  key2: value-{{ .Release.Name }}
</code></pre>

<p><strong>configmap.yaml</strong></p>

<pre><code>kind: ConfigMap
data:
  config-file: |
    {{- range $key, $value := .Values.config }}
    {{ $key }} = {{ $value }}
    {{- end }}
</code></pre>

<p>Where the desired output with would be:</p>

<p><strong>helm template --name v1 mychart/</strong></p>

<pre><code>kind: ConfigMap
data:
  config-file: |
    key1 = value
    key2 = value-v1
</code></pre>

<p>I've tried a few variations using template functions and pipelining, but to no avail:</p>

<pre><code>{{ $key }} = {{ tpl $value . }}
{{ $key }} = {{ $value | tpl . }}
{{ $key }} = {{ tpl $value $ }}
</code></pre>

<p>The above would also have worked in this way</p>
<p><strong>values.yaml</strong></p>
<pre><code>config:
  key1: &quot;value&quot;
  key2: &quot;value-{{ .Release.Name }}&quot;
</code></pre>
<p><strong>configmap.yaml</strong></p>
<pre><code>kind: ConfigMap
data:
  config-file: |
    {{- range $key, $value := .Values.config }}
    {{ $key }} = {{ tpl $value $ }}
    {{- end }}
</code></pre>
<p>What I changed was : I put value in quotes in <code>value.yaml</code> and used template <code>tpl</code> in the config map.</p>
