$ oc set env <object-selection> --list [<common-options>]
Azure Red Hat OpenShift 3.11 will be retired 30 June 2022. Support for creation of new Azure Red Hat OpenShift 3.11 clusters continues through 30 November 2020. Following retirement, remaining Azure Red Hat OpenShift 3.11 clusters will be shut down to prevent security vulnerabilities.
Follow this guide to create an Azure Red Hat OpenShift 4 cluster. If you have specific questions, please contact us
Azure Red Hat OpenShift provides the oc set env
command to set or unset environment
variables for objects that have a pod
template, such as
replication controllers or deployment configurations. It can also list
environment variables in pods or any object that has a pod template. This
command can also be used on BuildConfig
objects.
To list environment variables in pods or pod templates:
$ oc set env <object-selection> --list [<common-options>]
This example lists all environment variables for pod p1
:
$ oc set env pod/p1 --list
To set environment variables in the pod templates:
$ oc set env <object-selection> KEY_1=VAL_1 ... KEY_N=VAL_N [<set-env-options>] [<common-options>]
Set environment options:
Option | Description |
---|---|
|
Set given key value pairs of environment variables. |
|
Confirm updating existing environment variables. |
In the following example, both commands modify environment variable STORAGE
in the deployment config registry
.
The first adds, with value /data
.
The second updates, with value /opt
.
$ oc set env dc/registry STORAGE=/data $ oc set env dc/registry --overwrite STORAGE=/opt
The following example finds environment variables in the current shell whose names begin with RAILS_
and adds them to the replication controller r1
on the server:
$ env | grep ^RAILS_ | oc set env rc/r1 -e -
The following example does not modify the replication controller defined in file rc.json
.
Instead, it writes a YAML object with updated environment STORAGE=/local
to new file rc.yaml
.
$ oc set env -f rc.json STORAGE=/opt -o yaml > rc.yaml
Variable Name |
---|
|
|
Example Usage
The service KUBERNETES which exposes TCP port 53 and has been allocated cluster IP address 10.0.0.11 produces the following environment variables:
KUBERNETES_SERVICE_PORT=53 MYSQL_DATABASE=root KUBERNETES_PORT_53_TCP=tcp://10.0.0.11:53 KUBERNETES_SERVICE_HOST=10.0.0.11
Use the |
To unset environment variables in the pod templates:
$ oc set env <object-selection> KEY_1- ... KEY_N- [<common-options>]
The trailing hyphen ( |
This example removes environment variables ENV1
and ENV2
from deployment config d1
:
$ oc set env dc/d1 ENV1- ENV2-
This removes environment variable ENV
from all replication controllers:
$ oc set env rc --all ENV-
This removes environment variable ENV
from container c1
for replication controller r1
:
$ oc set env rc r1 --containers='c1' ENV-