Reputation: 4732
I would like the set the same env variable to the same value on all the containers of my pod. I am not trying to pass info between containers so this variable will not be updated but I want to ensure that if somebody update its value, it will be kept in sync across all the containers in my pod.
Is there any way to do this out of the box? Currently I see two options:
fieldRef
on the others.But Pods being a "single unit" it seems odd that there wouldn't be a way to define "pod-wide" env variables.
Upvotes: 3
Views: 3627
Reputation: 14084
There are a few ways.
The most common practice is as you mention using ConfigMap
. This way is explain in Kubernetes docs.
Another option is to use Secret, however it's similar to ConfigMap
way.
If you know that variable before deploying, you can Define an environment variable for a container
Last method is to set them manually in each container, however it's harsh way.
There is also a good comparsion of passing environmental variable
in medium article.
Upvotes: 3