<p>I'm trying to use Kustomize to generate ConfigMaps from files that contain key-value pairs. My <em>kustomization</em> file contains this:</p>

<pre class="lang-yaml prettyprint-override"><code>configMapGenerator:
    - name: my-config
      files:
          - environment.properties
</code></pre>

<p>The environment.properties file contains this:</p>

<pre><code>FIRST: 1
SECOND: 2
LAST: 3
</code></pre>

<p>The generated output contains this:</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
data:
  environment.properties: |
    FIRST: 1
    SECOND: 2
    LAST: 3
kind: ConfigMap
</code></pre>

<p>How can I flatten this data structure? I'd rather have this output instead:</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
data:
  FIRST: 1
  SECOND: 2
  LAST: 3
kind: ConfigMap
</code></pre>

<p>This is not flattening. This will remove file name under which those <code>key=value</code> pairs are present.</p>
<p>If you want simple flat output as you showed, you should use <code>literals</code>:</p>
<pre><code>configMapGenerator: 
- name: the-map 
  literals: 
    - FIRST: 1
    - SECOND: 2
    - LAST: 3
</code></pre>
<p>This is explained on <a href="https://kubectl.docs.kubernetes.io/pages/reference/kustomize.html" rel="nofollow noreferrer"># Kustomization.yaml Reference</a></p>
<blockquote>
<p><strong>files</strong>  []string</p>
<p>List of files to generate ConfigMap data entries from. Each item should be a path to a local file, e.g.  <code>path/to/file.config</code>, and the filename will appear as an entry in the ConfigMap data field with its contents as a value.</p>
<p><strong>literals</strong> []string</p>
<p>List of literal ConfigMap data entries. Each item should be a key and literal value, e.g.  <code>somekey=somevalue</code>, and the key/value will appear as an entry in the ConfigMap data field.</p>
</blockquote>
<pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
# generate a ConfigMap named my-java-server-props-&lt;some-hash&gt; where each file
# in the list appears as a data entry (keyed by base filename).
- name: my-java-server-props
  files:
  - application.properties
  - more.properties
# generate a ConfigMap named my-java-server-env-vars-&lt;some-hash&gt; where each literal
# in the list appears as a data entry (keyed by literal key).
- name: my-java-server-env-vars
  literals:    
  - JAVA_HOME=/opt/java/jdk
  - JAVA_TOOL_OPTIONS=-agentlib:hprof
# generate a ConfigMap named my-system-env-&lt;some-hash&gt; where each key/value pair in the
# env.txt appears as a data entry (separated by \n).
- name: my-system-env
  env: env.txt
</code></pre>
<p>EDIT:</p>
<p>As pointed by <a href="https://stackoverflow.com/users/1288449/steven-liekens">@Steven Liekens</a> this answers the question:</p>
<blockquote>
<p><strong>env</strong>    string</p>
<p>Single file to generate ConfigMap data entries from. Should be a path to a local env file, e.g. path/to/file.env, where each line of the file is a key=value pair. Each line will appear as an entry in the ConfigMap data field.</p>
</blockquote>
