<p>I am trying to use Patch and Put API to modify the podspec, I am able to update container images version with both Patch and Put API.
But I am not able to modify the Env variables for pod, I want to update Env variables, Can you please help here. Attached is the image<a href="https://i.stack.imgur.com/jUP1D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jUP1D.png" alt="enter image description here" /></a></p>

<p>Patching Pod may not change fields other than <code>spec.containers[*].image</code>, <code>spec.initContainers[*].image</code>, <code>spec.activeDeadlineSeconds</code> or <code>spec.tolerations</code> (only additions to existing tolerations).</p>
<p>Env variables are immutable for pods because this information is set when the pod gets created. So what you need is only achievable using a Deployment instead of a Pod.</p>
<p>When you update a env variable in a Deployment, all pods will be recreated to make changes happen.</p>
<p>An easier method to set/change variables is to make use of <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-env-em-" rel="nofollow noreferrer">kubectl set env</a>.</p>
<pre><code>kubectl set env deployment/test LOG_LEVEL=ERROR
</code></pre>
