Bootstrap FreeKB - OpenShift - List environment variables using the oc set env command
OpenShift - List environment variables using the oc set env command

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

There are different ways to configure a container with environment variables.

The oc set env command with the --list option can be used the list the environment variables associate with a resource, such as a deployment.

~]$ oc set env deployment my-deployment --list
# deployments/my-deployment, container my-container
# FOO from secret my-secret, key foo
my-environment-variable=Hello World

 

Or a pod.

~]$ oc set env pod my-pod-276pc --list
# pods/my-pod-276pc, container my-container
# FOO from secret my-secret, key foo
my-environment-variable=Hello World

 

Or a replica set.

~]$ oc set env replicaset my-deployment-5755cd7b85 --list
# replicasets/my-deployment-5755cd7b85, container my-container
# FOO from secret my-secret, key foo
my-environment-variable=Hello World

 

The --all flag can be used to list the environment variables for all of a particular resource, such as all deployments, pods or replica sets in the currently selected project / namespace.

~]$ oc set env pod --all --list
# pods/my-pod-276pc, container y-container
# FOO from secret my-secret, key foo
my-environment-variable=Hello World
# pods/my-pod-k8vr2, container my-container
# foo-secret from secret my-secret, key foo
my-environment-variable=Hello World

 

Also, the oc exec command and the env or printenv command can be used to list the environment variables in a pod.

~]$ oc exec/my-pod-65rbl -- env
foo-secret=Hello
bar-secret=World

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 12a29d in the box below so that we can be sure you are a human.