<p>I can create a ConfigMap without issues with <code>kubectl create configmap settings --from-file settings.yaml</code>, but I don't want to manually create it but as part of a <code>helm install</code>.</p>
<p>So, I created a template file:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.settingsConfigMap }}
data:
  settings.yaml: |-
{{ .Files.Get &quot;settings.yaml&quot; | indent 4}}
</code></pre>
<p>but whenever I run <code>helm install</code> I get an error saying that</p>
<blockquote>
<p>invalid type for io.k8s.api.core.v1.ConfigMap.data: got &quot;map&quot;,
expected &quot;string&quot;</p>
</blockquote>
<p>So, what can I do to create this ConfigMap with Helm loading the content from a YAML file?</p>
<p><strong>UPDATE</strong></p>
<p>It turns out the error mentioned above is related to some issues with the indentation. By removing the <code>indent 4</code>, I managed to get a step further, but now it's failing because all my settings are detected as <code>unknown fields</code>, for example:</p>
<blockquote>
<p>unknown field &quot;customers&quot; in io.k8s.api.core.v1.ConfigMap, ValidationError(ConfigMap): unknown field &quot;deploy_name&quot; in io.k8s.api.core.v1.ConfigMap, ValidationError(ConfigMap): unknown field &quot;system&quot; in io.k8s.api.core.v1.ConfigMap</p>
</blockquote>
<p><code>deploy_name</code>, <code>system</code> and <code>customers</code> are the top level keys of my settings.yaml file.</p>

<p>I found the answer.</p>
<p>The error mentioned in the update is the outcome of removing <code>indent 4</code>. By removing that, the YAML used by Helm is screwed up, hence that's why it doesn't understand those fields.</p>
<p>So, why did it fail when I had the <code>indent 4</code>? The reason is the missing white space before the <code>}</code>. With <code>{{ .Files.Get &quot;settings.yaml&quot; | indent 4 }}</code>, everything is good.</p>
