We aware of that we can define environment variables in pod/containers. i wanted to use the same environment variable inside the container at runtime.
ex: i am running a webapplication using python , inside that how to i get the values of environment values?
Accessing environment variables is pretty easy with the os
module.
import os
os.environ.get("ENV_VAR_NAME")
First go inside the pod or exec
the bash
(kubeclt exec -it <pod_name> bash
) and run printenv
to get some idea what are the environmental variables available.
From Python
import os
os.environ['MYCUSTOMVAR']