Kubernetes environment variable update policy

5/22/2020

I'm writing an application that dynamically deploys kubernetes resources. On each deploy, I set environment variables in the Container within the DeploymentSpec with the golang api (see https://godoc.org/k8s.io/api/core/v1#Container). Is there any reason why I'm not seeing changes in these variables on the pod?

For example, when I change my codebase to set FOO: "hi" to FOO: "hello", the variable isn't updated in the application.

Based on other answers, its probably important to note that my "checking" of the environment variables is happening at docker run time. That is, for debugging, I'm running printenv in the CMD field of the kubernetes container.

A snippet of env variables being printed before Create() on the deployment:

...

v1.EnvVar{
   Name:      "FOO",
   Value:     "foo",
},
v1.EnvVar{
   Name:      "BAR",
   Value:     "arb",
},

...

Any leads are greatly appreciated!

-- Jay K.
docker
kubernetes
kubernetes-apiserver
kubernetes-pod

0 Answers