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
Patching Pod may not change fields other than spec.containers[*].image
, spec.initContainers[*].image
, spec.activeDeadlineSeconds
or spec.tolerations
(only additions to existing tolerations).
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.
When you update a env variable in a Deployment, all pods will be recreated to make changes happen.
An easier method to set/change variables is to make use of kubectl set env.
kubectl set env deployment/test LOG_LEVEL=ERROR