Accessing OpenShift through the command line
-
Download the OpenShift terminal client (
oc
executable) to your workstation. Note: Some commands require a recent version ofoc
so re-download if you have an old version.- Windows
- Linux
-
- On macOS, you may need to remove the download quarantine before extracting the file. Open
Terminal
, change directory to where you downloaded the file and run:xattr -d com.apple.quarantine openshift*
- On macOS, you may need to remove the download quarantine before extracting the file. Open
-
- On macOS, you may need to remove the download quarantine before extracting the file. Open
Terminal
, change directory to where you downloaded the file and run:xattr -d com.apple.quarantine openshift*
- On macOS, you may need to remove the download quarantine before extracting the file. Open
-
Unzip/extract the
openshift-client-*
download into some directory - Open a
Terminal
orCommand Prompt
application and change directory to where you expanded theopenshift-client-*
download -
Add this directory to your
PATH
by replacing$OCDIR
with this directory:-
macOS/Linux:
export PATH=$OCDIR:$PATH
For example:
export PATH=${HOME}/Downloads/openshift-client-mac/:$PATH
-
Windows Command Prompt:
set PATH=$OCDIR;%PATH%
For example:
set PATH=%HOMEPATH%\Downloads\openshift-client-windows\;%PATH%
-
Windows Cygwin terminal:
export PATH=$OCDIR:$PATH
For example:
export PATH=${HOMEPATH}/Downloads/openshift-client-windows/:$PATH
-
-
Open your browser to the OpenShift web console at https://console-openshift-console.$CLUSTER_DOMAIN_NAME/
- In the top right, click on your name } Copy Login Command } Log-in again } Display Token } Copy the
oc login
command
- Paste and run the
oc login
command in theTerminal
orCommand Prompt
opened in step 3 above.- The most common error is
certificate is not trusted
when using a test cluster. In this case, add--insecure-skip-tls-verify
. - See the Frequently Asked Questions (FAQ) for other common login errors.
- The most common error is
- Run
oc whoami
to confirm everything works. - If you have been provided a namespace that you should use, then set your current namespace, replacing
$NAMESPACE
in the following command:oc config set-context --current --namespace $NAMESPACE