<p>I have containerized node.js application into kubernetes pod. To set few of the Environment variables, I have created .env.k8 file and setting up few env variables there.</p>
<p>While building the image, I am choose this file as --env =k8 in docker build command. Suppose, I have set one ENV Varible in that .env.k8 file as URL =&quot;abc.com&quot;</p>
<p>Image is getting created and pod is up. I need to check if the process.env.URL is set as per my .env.k8 file. Is there any way from pod, I can check if the Env variables are set correctly.</p>
<p>I exec into running container and used commond printenv. It is not showing the process env variables for node.js application, it is showing Env variables set for POD.</p>
<p>So how to check process.env variables from a kubernetes pod of the same</p>

iRunner
<p>You will have to define create a configMap from  your .env file and mount it in your app's root.</p>
<pre><code>kubectl create configmap nodejs-env --from-file=.env.k8 
</code></pre>
<p>When properly mounted, the .env file will set the env variables for your Node.js application</p>
<pre><code># NodoJS app Deployment using above config map

apiVersion: app/v1
kind: Deployment
metadata:
  name: nodejs-app
  namespace: production
spec:
  replicas: 8
  selector:
    matchLabels:
      app: nodejs-app
  template:
    metadata:
      labels:
        app: nodejs-app
    spec:
      containers:
      - name: nodejs-app
        image: nodejs-app:3.2.0
        ports:
          containerPort: 80
        volumeMounts:
        - name: nodejs-env-file
          mountPath: /app/.env
          readOnly: true
    volumes:
    - name: nodejs-env-file
      configMap:
        name: nodejs-env
</code></pre>
<p>Reference: <a href="https://www.cloudytuts.com/tutorials/kubernetes/how-to-configure-node-based-apps-in-kubernetes/" rel="nofollow noreferrer">https://www.cloudytuts.com/tutorials/kubernetes/how-to-configure-node-based-apps-in-kubernetes/</a></p>
