<p>Is there a way to store yaml data in a config map?</p>
<p>In my <code>values.yaml</code> I have something like the below</p>
<pre><code>config:
  filters:
    - kind: Pod
      apiVersion: v1
...
</code></pre>
<p>In my config map, I'm currently doing</p>
<pre><code>...
data:
  config.yaml: |-
    {{ .Values.config }}
</code></pre>
<p>But in the resulting <code>configmap</code> the data is &quot;inlined&quot; and formatted as this</p>
<pre><code>...
data:
  config.yaml: &gt;-
    map[filters:[map[apiVersion:v1...
</code></pre>
<p>Which isn't <code>yaml</code> and therefore can't be parsed by the app reading it.</p>

<p>Let's say  you have a <code>demo-chart</code>:</p>
<pre><code>.
└── demo
    ├── charts
    ├── Chart.yaml
    ├── templates
    │   ├── configmap.yaml
    │   ├── _helpers.tpl
    │   └── NOTES.txt
    └── values.yaml

</code></pre>
<p><strong>values.yaml:</strong></p>
<pre class="lang-yaml prettyprint-override"><code>config:
  filters:
    - kind: Pod
      apiVersion: v1
</code></pre>
<p><strong>configmap.yaml:</strong></p>
<pre class="lang-yaml prettyprint-override"><code>{{- if .Values.config }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: demo-name
data:
  config.yml: |- {{- toYaml .Values.config | nindent 4 }}
{{- end }}
</code></pre>
<p><strong>Explanation:</strong> <code>toYaml</code> parse the data loaded from the values.yaml into YAML and <code>nindent</code> put 4 spaces in front of every line.</p>
<p><strong>Check:</strong></p>
<pre class="lang-sh prettyprint-override"><code>$ helm template demo
---
# Source: demo/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: demo-name
data:
  config.yml: |-
    filters:
    - apiVersion: v1
      kind: Pod
</code></pre>
