<p>I am trying to make a simple config map from a config.txt file:</p>
<pre><code>config.txt:
----------
key1=val1
key2=val2
</code></pre>
<p>this is the pod yaml:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx
    name: nginx
    command: [ &quot;/bin/sh&quot;, &quot;-c&quot;, &quot;env&quot; ]
    env:
      - name: KEY_VALUES
        valueFrom:
          configMapKeyRef:
            name: keyvalcfgmap
            key1: key1
            key2: key2
</code></pre>
<p>by running <code> kubectl create configmap keyvalcfgmap --from-file=&lt;filepath&gt;  -o yaml &gt; configmap.yaml</code> and applying the created configmap, I supposedly can use it in a pod. the question is how? I tried adding it as a volume or calling it using <code>--from-file=</code> and even <code>envFrom</code> but the best I could get was that the volume just mounted the file itself and not the configmap.</p>

Killerz0ne
<p>You can use <code>envFrom</code> like this</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
  - name: test-container
    image: k8s.gcr.io/busybox
    command: [ &quot;/bin/sh&quot;, &quot;-c&quot;, &quot;env&quot; ]
    envFrom:
    - configMapRef:
        name: keyvalcfgmap        #&lt;--------------Here
  restartPolicy: Never
</code></pre>
<p>or you can use configmap as <code>env</code> variables</p>
<pre><code>env:
  - name: NAME
    valueFrom:
      configMapKeyRef:
        name: keyvalcfgmap        #&lt;--------------Here
        key: key1
  - name: NAME
    valueFrom:
      configMapKeyRef:
        name: keyvalcfgmap       #&lt;--------------Here
        key: key2
</code></pre>
