<p>I would like the set the same env variable to the same value on all the containers of my pod. I am not trying to pass info between containers so this variable will not be updated but I want to ensure that if somebody update its value, it will be kept in sync across all the containers in my pod.</p>
<p>Is there any way to do this out of the box? Currently I see two options:</p>
<ul>
<li>The ugly one would be to set the value on one container and use a <code>fieldRef</code> on the others.</li>
<li>The less ugly would be to create a new ConfigMap and use envFrom in all the containers.</li>
</ul>
<p>But Pods being a &quot;single unit&quot; it seems odd that there wouldn't be a way to define &quot;pod-wide&quot; env variables.</p>

ITChap
<p>There are a few ways.</p>
<ol>
<li><p>The most common practice is as you mention using <code>ConfigMap</code>. This way is explain in <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">Kubernetes docs</a>.</p>
</li>
<li><p>Another option is to use <a href="https://kubernetes.io/docs/concepts/configuration/secret/#using-secrets-as-environment-variables" rel="nofollow noreferrer">Secret</a>, however it's similar to <code>ConfigMap</code> way.</p>
</li>
<li><p>If you know that variable before deploying, you can <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container" rel="nofollow noreferrer">Define an environment variable for a container</a></p>
</li>
<li><p>Last method is to set them manually in each container, however it's harsh way.</p>
</li>
</ol>
<p>There is also a good comparsion of passing <code>environmental variable</code> in <a href="https://medium.com/@caboadu/environment-variables-4-ways-to-set-them-in-kubernetes-bc7c8ceb333d" rel="nofollow noreferrer">medium article</a>.</p>
