We are using Kubernetes v1.1.0-beta and I am curious if Kubernetes supports env_file
, like Docker Compose? On Pod/ReplicationController creation it would read in the file specified by env_file and set the variables on that pod. Is this a thing or just env
map?
No. Kubernetes does not support
evv_file
as of now. You will have to specifykey=value
pairs for env variables.You can use a config map to achieve this. So you deploy a configmap with the key value pairs you want, this stays stable across deployments. You can even deploy multiple config maps, so you could have different values for different environments.
Then in your pod yaml file, you would do something like this to expose the configmap values as an env variable
Read more here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data
If there is any sensitive data (like passwords, db connection URIs etc), you should use secrets instead. Unlike configmaps, secrets are obscured.
More info here -> https://kubernetes.io/docs/concepts/configuration/secret/