<p>I'm playing around with kubernetes ConfigMaps. In the <a href="https://kubernetes.io/docs/concepts/configuration/configmap/#configmaps-and-pods" rel="nofollow noreferrer">official documentation</a>, I see &quot;file-like keys&quot; in the <code>data</code> field:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: game-demo
data:
  # file-like keys
  game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5    
  user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true    
</code></pre>
<p>Is it possible to break these &quot;file-like keys&quot; into different files and reference them in this ConfigMap resource?</p>
<p>I see several benefits of this approach:</p>
<ul>
<li>Slimmed down ConfigMap</li>
<li>Proper syntax highlighting for the &quot;file-like&quot; configurations</li>
<li>Can run auto formatters against the &quot;file-like&quot; configurations</li>
</ul>

<blockquote>
<ul>
<li>Proper syntax highlighting for the &quot;file-like&quot; configurations</li>
<li>Can run auto formatters against the &quot;file-like&quot; configurations</li>
</ul>
</blockquote>
<p>Yes, it is easier to save the files as proper files on your machine and in Git.</p>
<p>I propose that you use the <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/" rel="nofollow noreferrer">kustomize feature of kubectl</a> and use <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/#configmapgenerator" rel="nofollow noreferrer">configMapGenerator</a> to generate the ConfigMap instead.</p>
<p>Example <code>kustomization.yaml</code> (saved in the same directory as your files, e.g. in <code>config/</code>)</p>
<pre><code>configMapGenerator:
- name: game-demo
  files:
  - game.properties
  - user-interface.properties
</code></pre>
<p>Then you can apply (and generate the configMap) with (if your config is in <code>config/</code>):</p>
<pre><code>kubectl -k config/
</code></pre>
<p>Or you can preview the &quot;generated&quot; configMap with:</p>
<pre><code>kubectl kustomize config/
</code></pre>
