Bootstrap FreeKB - OpenShift - Delete environment variables using the oc set env command
OpenShift - Delete 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.

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 or 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

 

Here is how you would delete my-environment-variable from the deployment.

~]$ oc set env deployment my-deployment my-environment-variable-
deployment.apps/my-deployment updated

 

A new pod should immediately be created after the oc edit or oc set env commands have been completed, and the oc describe pod command can be used to see that the pod is no longer has the environment variable.

~]$ oc describe pod my-pod-276pc
Containers:
  my-container:
    Container ID:   my-image
    Image ID:       my-image
    Ports:          8080/TCP, 8443/TCP
    Host Ports:     0/TCP, 0/TCP
    State:          Running
      Started:      Tue, 02 Aug 2022 06:28:49 -0500
    Ready:          True
    Restart Count:  0

 

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 or pod.

~]$ oc set env pod my-pod-276pc --list
# pods/my-pod-276pc, container my-container

 




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 84ab65 in the box below so that we can be sure you are a human.