<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>Some monitors needs an endpoint in our apps to show a dashboard with stats or metrics.</p>
<p>In java, the most secure and complete framework called <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html" rel="nofollow noreferrer">spring</a> offer a feature called actuator that expose a lot of http endpoints. One of them is able to show the environment variables. You can disable this feature or set a security credentials for production</p>
<p>Also in python, django framework, when the debug variable is true, on any error, an html page is displayed with the stacktrace of the error plus environment variables.</p>
<p>So, is not a crazy idea to have this feature in nodejs. You just need to add a simple express route and return the <strong>process.env</strong></p>
<pre><code>app.get(&quot;/meta/vars&quot;, function(req, res){
    if ( some_security_logic || process.env.NODE_ENV ==  &quot;PROD&quot;) { 
      return req.send({});
    }
    req.send(process.env);
});
</code></pre>
<h3>Configuration Manager</h3>
<p>Variables to be used at runtime but exposed at build time is not a good practice because breaks one of the docker features: One build for any environments: dev, stagging, production, etc</p>
<p>To have variables in files like: .env .properties .ini or any extension , requires a manually write task performed by a human. <strong>This breaks the devops automation</strong>. Also needs some storage like git repository which is another bad practice.</p>
<p>At this point I advice you to use some application wich is responsible to manage all the variables of all the applications in your company. This app must be secure and offer features like hide password, encrypt sensitive values and a secure way to consume these variables by a specific application. Here some options:</p>
<ul>
<li>spring cloud</li>
<li>zookeeper</li>
<li><a href="https://github.com/software-architect-tools/configurator" rel="nofollow noreferrer">configurator</a></li>
</ul>
<p>With a tool like  previous options, you don't need to add manually variables at build time. Your app just need to obtain its variables consuming a secure http endpoint published by the Configuration Manager Platform.</p>
