Explore OpenShift

The Web Console

OpenShift ships with a web-based console that will allow users to perform various tasks via a browser.

  • ROKS

  • Others

Login to IBM Cloud, copy this link and open in your browser:

%LOGIN%

Enter following credentials:

Username:

%USERNAME%

Password:

%PASSWORD%

Click Sign In.

ROKS Login

After you successfully logged in, from right side pane, click OpenShift web console to access your OpenShift Cluster Dashboard:

ROKS Open-shift web console

To get a feel for how the web console works, click on this Web Console link.

On the login screen, enter the following credentials:

Username:

%USERNAME%

Password:

%PASSWORD%

The first time you access the web console, you will most likely be in the Administrator perspective. If you are also the Cluster Administrator, you will be presented with an overview of the whole Cluster status:

Web Console Overview

Command Line Interface

OpenShift ships with a feature rich web console as well as command line tools to provide users with a nice interface to work with applications deployed to the platform. The OpenShift tools are a single executable written in the Go programming language and is available for the following operating systems:

  • Microsoft Windows

  • Mac OS X

  • Linux

You might already have the OpenShift CLI available on your environment. You can verify it by running an oc command:

oc version

You should see the following (or something similar):

Client Version: openshift-clients-4.5.0-202006231303.p0-9-ge40bd2dd9
Server Version: 4.5.11
Kubernetes Version: v1.18.3+b0068a8

If the oc doesn’t exist or you have an older version of the OpenShift CLI, follow the next sections to install or update the OpenShift CLI. Otherwise, skip to the next lab.

Download CLI

From top right menu bar, click to the little white question mark icon, then click to Command Line Tools:

Download CLI

Scroll down to oc - OpenShift Command Line Interface (CLI)

CLI Binaries

Download and Install OpenShift CLI on Linux

Once the file has been downloaded, you will need to extract the contents as it is a compressed archive. I would suggest saving this file to the following directories:

~/OpenShift

Open up a terminal window and change to the directory where you downloaded the file. Once you are in the directory, enter in the following command:

The name of the oc packaged archive may vary. Adjust accordingly.
tar zxvf oc-linux.tar.gz

The tar.gz file name needs to be replaced by the entire name that was downloaded in the previous step.

Now you can add the OpenShift CLI tools to your PATH.

export PATH=$PATH:~/openShift

At this point, we should have the oc tool available for use. Let’s test this out by printing the version of the oc command:

oc version

You should see the following (or something similar):

Client Version: openshift-clients-4.5.0-202006231303.p0-9-ge40bd2dd9
Server Version: 4.5.11
Kubernetes Version: v1.18.3+b0068a8

If you get an error message, you have not updated your path correctly. If you need help, raise your hand and the instructor will assist.

Download and Install OpenShift CLI on Mac OS X

Once the file has been downloaded, you will need to extract the contents as it is a compressed archive. I would suggest saving this file to the following directories:

~/OpenShift

Open up a terminal window and change to the directory where you downloaded the file. Once you are in the directory, enter in the following command:

The name of the oc packaged archive may vary. Adjust accordingly.
tar zxvf oc-macosx.tar.gz

The tar.gz file name needs to be replaced by the entire name that was downloaded in the previous step.

Now you can add the OpenShift CLI tools to your PATH.

export PATH=$PATH:~/OpenShift

At this point, we should have the oc tool available for use. Let’s test this out by printing the version of the oc command:

oc version

You should see the following (or something similar):

Client Version: openshift-clients-4.5.0-202006231303.p0-9-ge40bd2dd9
Server Version: 4.5.11
Kubernetes Version: v1.18.3+b0068a8

If you get an error message, you have not updated your path correctly. If you need help, raise your hand and the instructor will assist.

Download and Install OpenShift CLI on Mac OS X using HomeBrew

If you have HomeBrew installed (www.brew.sh) you can install OpenShift CLI using brew:

brew install openshift-cli

You may also want to enable CLI autocompletion (bash or zsh):

source <(oc completion bash)
source <(oc completion zsh)

To make CLI autocompletion persistent (bash or zsh) by adding a relevant line to your .bashrc or .zshrc:

oc completion bash > oc_bash_completion.sh
oc completion bash > oc_zsh_completion.sh

source oc_bash_completion.sh
source oc_zsh_completion.sh

Download and Install OpenShift CLI on Windows

The CLI for Windows is provided as a zip archive. Download and unzip the archive with a ZIP program and move the oc binary to a directory on your PATH. To check your PATH, open the Command Prompt and run:

path

Checkout this blog post if you’d like to set it up with Powershell

At this point, we should have the oc tool available for use. Let’s test this out by printing the version of the oc command:

oc version

You should see the following (or something similar):

Client Version: openshift-clients-4.5.0-202006231303.p0-9-ge40bd2dd9
Server Version: 4.5.11
Kubernetes Version: v1.18.3+b0068a8

If you get an error message, you have not updated your path correctly. If you need help, raise your hand and the instructor will assist.

Connect to the OpenShift Cluster from CLI

Once your oc client is setup on your Workstation, you can connect to cluster and start working also with OpenShift CLI.

From Web Console overview, go to top-right menu bar and click to the dropdown menu containing your username, then click Copy Login Command:

Copy Login Command

Click on Display Token and copy the command under Login with this token:

Example:

oc login --token=some_token --server=https://c104-e.us-east.containers.cloud.ibm.com:32208
Logged into "https://c104-e.us-east.containers.cloud.ibm.com:32208" as "%USERNAME%" using the token provided.

You have access to 68 projects, the list has been suppressed. You can list all projects with 'oc projects'

Using project "default".

Working with proxies

It might happen that you’re behind a corporate proxy to access the internet. In this case, you’ll need to set some additional environment variables for the oc command line to work.

Windows: Follow previous section’s instructions on how to set an Environment Variable on Windows. The variables you’ll need to set are:

Replace the proxy server with the one for your environment/machine.
https_proxy=http://proxy-server.mycorp.com:3128/
HTTPS_PROXY=http://proxy-server.mycorp.com:3128/

Mac OS X:

Replace the proxy server with the one for your environment/machine.
export https_proxy=http://proxy-server.mycorp.com:3128/
export HTTPS_PROXY=http://proxy-server.mycorp.com:3128/

Linux:

Replace the proxy server with the one for your environment/machine.
export https_proxy=http://proxy-server.mycorp.com:3128/
export HTTPS_PROXY=http://proxy-server.mycorp.com:3128/

If the proxy is secured, make sure to use the following URL pattern, replacing the contents with the appropriate values:

export https_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/

Special Characters: If your password contains special characters, you must replace them with ASCII codes, for example the at sign @ must be replaced by the %40 code, e.g. p@ssword = p%40ssword.