<p>I created EKS cluster and now i need to add http_proxy/http_proxies and no_proxy as environment variable to all 300 deployments. I created a config map with the variables. Is there a way to update all pods simultaneously without doing it one by one? And if yes how can i do it? My config map name is proxy-environment-variables.</p>
<p>Thank you for the help and assistance!</p>
<p>BR,</p>
<p>Martin</p>
<pre><code>Name:         proxy-environment-variables
Namespace:    kube-system
Labels:       &lt;none&gt;
Annotations:  &lt;none&gt;

Data
====
HTTPS_PROXY:
----
http://10.16.11.10:8080
HTTP_PROXY:
----
http://10.16.11.10:8080
NO_PROXY:
----
169.254.169.254,127.0.0.1,localhost,10.0.0.0/8
http_proxy:
----
http://10.16.11.10:8080
https_proxy:
----
http://10.16.11.10:8080
no_proxy:
----
169.254.169.254,127.0.0.1,localhost,10.0.0.0/8

BinaryData
====

Events:  &lt;none&gt;

</code></pre>

<p>You can use the <code>set env</code> to update the environment variable into the deployment:</p>
<pre><code>kubectl set env deployment --all  --from=configmap/my-env-config
</code></pre>
<p>Example: The following example is demonstrating if there are multiple deployments, how to add env variables to their pods.</p>
<p>// I have the following deployments:</p>
<pre><code>kubectl get deployment
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
dep-1   1/1     1            1           5m21s
dep-2   1/1     1            1           41m
dep-4   1/1     1            1           3m17s
</code></pre>
<p>// their respective pods:</p>
<pre><code>kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
dep-1-84fcdf5-wblsm      1/1     Running   0          2m8s
dep-2-84fcdf5-qfbd5      1/1     Running   0          3m4s
dep-4-6cf4dcf794-wk476   1/1     Running   0          4s
</code></pre>
<p>// my config map:</p>
<pre><code>apiVersion: v1
data:
  HTTP_PROXY: https://1.2.3.4:1234
kind: ConfigMap
metadata:
  creationTimestamp: &quot;2022-05-04T16:52:00Z&quot;
  name: my-env-config
  namespace: default
  resourceVersion: &quot;1002232&quot;
  uid: c8606312-90c6-45cf-86f0-f4f874f19909    
</code></pre>
<p>// HTTP_PROXY env variable is <strong>already</strong> set in dep-1</p>
<pre><code>kubectl exec -it dep-1-84fcdf5-wblsm -- printenv HTTP_PROXY
https://1.2.3.4:1234
</code></pre>
<p>// HTTP_PROXY env variable is <strong>already</strong> set in dep-2</p>
<pre><code>kubectl exec -it dep-2-84fcdf5-qfbd5 -- printenv HTTP_PROXY
https://1.2.3.4:1234
</code></pre>
<p>// HTTP_PROXY env variable is <strong>not</strong> set in dep-4, <strong>this is our focus</strong></p>
<pre><code>kubectl exec -it dep-4-6cf4dcf794-wk476 -- printenv HTTP_PROXY
command terminated with exit code 1
</code></pre>
<p>// <strong>SOLUTION</strong>: Setting env for all the deployments(<code>--all</code>) from a config map called <code>my-env-config</code>)</p>
<pre><code> kubectl set env deployment --all  --from=configmap/my-env-config
deployment.apps/dep-4 env updated
</code></pre>
<p>//Note the age of the pods, only dep-4's pod age is altered</p>
<pre><code>kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
dep-1-84fcdf5-wblsm      1/1     Running   0          3m40s
dep-2-84fcdf5-qfbd5      1/1     Running   0          4m36s
dep-4-59d5cfd48d-2tbbm   1/1     Running   0          5s
</code></pre>
<p>// now HTTP_PROXY is set in dep-4's pod.</p>
<pre><code>kubectl exec -it dep-4-59d5cfd48d-2tbbm -- printenv HTTP_PROXY
https://1.2.3.4:1234
</code></pre>
