Environment variables values after Kubernetes Container Restart

2/5/2021

I am new to the kubernetes world and I have a basic doubt with respect to container restart. I have few environment variables set from values yaml during the creation of deployment. When the container restarts due to some reason, what happens to these environment variables ? Will they be having the values which were set at the time of pod creation ?

Please help me here.

-- ysn
kubernetes

1 Answer

2/5/2021

When a pod of a Deployment dies, a new pod is created from the spec defined in the Deployment. So, if you have overwritten the environment variable in the yaml spec (using kubectl edit, etc.), you'll see the values that was updated else you'll see the default values that were defined in the helm values while creating the Deployment.

Technically, the same applies to containers as well. It's just that if you have multiple containers within the pod and one of them dies, a new pod is not created but the container is restarted using the same values that is present in the pod spec that was created from Deployment spec.

-- Krishna Chaurasia
Source: StackOverflow