<p>I am trying to pass env variable to my pod from configmap. I have the following setup.</p>

<p>I have a file <strong>test-config.txt</strong> with 2 env variables </p>

<pre><code>a_sample_env=b
c_sample_env=d
</code></pre>

<p>I create a configmap as follows:</p>

<blockquote>
  <p>kubectl create configmap test-config --from-file test-config.txt</p>
</blockquote>

<p>My pod definition is as follows:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
  - name: mycontainer
    image: redis
    envFrom:
      - configMapRef:
          name: test-config
</code></pre>

<p>But my application doesn't receive the 2 env variables in the test-config.txt file. I logged into the pod using kubectl exec and get empty values for the env variables.</p>

<pre><code>root@test-pod:/data# echo $c_sample_env

root@test-pod:/data# echo $a_sample_env

</code></pre>

<p>Can anybody point out why the environment variables are not available in the pod?</p>

Malathi
<p>you should create configmap as below</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: special-config
  namespace: default
data:
  a_sample_env: b
  c_sample_env: d
</code></pre>

<p>if you create configmap using below command</p>

<pre><code>kubectl create configmap test-config --from-file test-config.txt
</code></pre>

<p>then you can mount test-config as volume inside container. You will have to create a wrapper/launch script to export all k:v pair from that file as env variable during startup</p>
