openshift CLI

UMLUseCase
IBM :: Troubleshhoting :: openshift CLI

Description

Installing the Red Hat OpenShift CLI

You can use the Red Hat® OpenShift® on IBM Cloud® command line interface (CLI) plug-in (ibmcloud oc) to create and manage your Red Hat OpenShift cluster infrastructure, such as creating clusters and worker nodes. Then, you can use the Red Hat OpenShift CLI (oc) to manage the resources within your Red Hat OpenShift cluster, such as projects, pods, and deployments. To use the API, see Setting up the API. Installing the IBM Cloud CLI and plug-ins

Install the required CLIs to create and manage your Red Hat OpenShift clusters in Red Hat OpenShift on IBM Cloud, and to deploy containerized apps to your cluster.

This task includes the information for installing these CLIs and plug-ins:

IBM Cloud CLI (ibmcloud)
Red Hat OpenShift on IBM Cloud plug-in (ibmcloud oc alias for Red Hat OpenShift clusters)
IBM Cloud Container Registry plug-in (ibmcloud cr)
IBM Cloud Kubernetes Service observability plug-in (ibmcloud ob)

If you want to use the IBM Cloud console instead, you can run CLI commands directly from your web browser in the IBM Cloud Shell.

To install the CLIs:

Install the stand-alone IBM Cloud CLI (ibmcloud).

Plan to use the CLI often? Try Enabling autocompletion for the IBM Cloud CLI (Linux/macOS only).

Log in to the IBM Cloud CLI. Enter your IBM Cloud credentials when prompted.

ibmcloud login

If you have a federated ID, use ibmcloud login --sso to log in to the IBM Cloud CLI. Enter your username and use the provided URL in your CLI output to retrieve your one-time passcode. You know you have a federated ID when the login fails without the --sso and succeeds with the --sso option.

Install the IBM Cloud plug-in for Red Hat OpenShift on IBM Cloud (ibmcloud oc). Use this plug-in to create and manage Red Hat OpenShift on IBM Cloud resources such as clusters, worker nodes, or network load balancers.

ibmcloud plugin install container-service

Install the IBM Cloud plug-in for IBM Cloud Container Registry (ibmcloud cr). Use this plug-in to set up your own namespace in a multi-tenant, highly available, and scalable private image registry that is hosted by IBM, and to store and share Docker images with other users. Docker images are required to deploy containers into a cluster.

ibmcloud plugin install container-registry

To create a logging configuration for IBM Log Analysis or a monitoring configuration for IBM Cloud Monitoring for your cluster, install the IBM Cloud Kubernetes Service observability plug-in (ibmcloud ob).

ibmcloud plugin install observe-service

Verify that the plug-ins are installed correctly.

ibmcloud plugin list

Example output

Listing installed plug-ins...

Plugin Name                            Version   Status
container-registry                     0.1.514
container-service/kubernetes-service   1.0.231
observe-service/ob                     1.0.61

For reference information about these CLIs, see the documentation for those tools.

ibmcloud commands
ibmcloud oc commands
ibmcloud cr commands

Installing the OpenShift Origin CLI (oc)

To view a local version of the Red Hat OpenShift dashboard and to deploy apps into your Red Hat OpenShift on IBM Cloud clusters, install the Red Hat OpenShift CLI (oc) and Kubernetes CLI (kubectl).

Using both community Kubernetes and Red Hat OpenShift clusters? Your clusters might run different versions of Kubernetes, such as 1.11 on Red Hat OpenShift and 1.25 on Ubuntu. Make sure to use the kubectl binary file that matches the +/- 1 skew policy for your cluster major.minor Red Hat OpenShift and Kubernetes versions. For supported versions, see Red Hat OpenShift versions.

Looking for a simple installation? You can try installing the plug-in with a package manager such as Homebrew. Keep in mind that the version skew might not match your cluster. For example, in Homebrew, you can update Homebrew by running brew update and check what version of the plug-in is installed by running brew info openshift-cli. Then, install the plug-in by running brew install openshift-cli.

Download the latest Red Hat OpenShift CLI (oc) for your local operating system and Red Hat OpenShift version. The current default Red Hat OpenShift version is 4.10. If you use Windows, install the oc CLI in the same directory as the IBM Cloud CLI. This setup saves you some file path changes when you run commands later. You can get the download link for oc from the Red Hat OpenShift web console, or manually from the mirror.openshift.com website.
    From the Red Hat OpenShift clusters console, select your cluster.
    Click Red Hat OpenShift web console.
    From the menu bar, click the information (question mark) icon.
    Click Command Line Tools.
    Click the download link for your operating system.

Download the Kubernetes CLI (kubectl) for your Red Hat OpenShift cluster. You might use different kubectl versions if you have community Kubernetes clusters that run other Kubernetes versions such as 1.25.6. For clusters that run Red Hat OpenShift, download the kubectl version that matches the Kubernetes version of your Red Hat OpenShift cluster. For supported versions, see Red Hat OpenShift versions.

If you have multiple clusters that run different versions of Kubernetes, you can download separate kubectl binary files. Then, set up an alias in your local command-line interface (CLI) profile to point to the separate binary files that match the version of kubectl your cluster needs.

Optional: Enable autocompletion for kubectl commands. The steps vary depending on the shell that you use. You can repeat the steps to enable autocompletion for oc commands. For example, in bash on Linux, instead of kubectl completion bash >/etc/bash_completion.d/kubectl, you can run oc completion bash >/etc/bash_completion.d/oc_completion.

Next, start Creating a Red Hat OpenShift on IBM Cloud cluster.

For more information about the oc CLI, see the Red Hat OpenShift documentation. Updating the CLI

Update the CLIs regularly to use new features.

This task includes the information for updating the following CLIs:

IBM Cloud CLI version 0.8.0 or later
Red Hat OpenShift on IBM Cloud plug-in
Red Hat OpenShift CLI
IBM Cloud Container Registry plug-in

To update the CLIs:

Update the IBM Cloud CLI. Download the latest version and run the installer.

Log in to the IBM Cloud CLI. Enter your IBM Cloud credentials when prompted.

ibmcloud login

If you have a federated ID, use ibmcloud login --sso to log in to the IBM Cloud CLI. Enter your username and use the provided URL in your CLI output to retrieve your one-time passcode. You know you have a federated ID when the login fails without the --sso and succeeds with the --sso option.

Install the update from the IBM Cloud plug-in repository.

ibmcloud plugin update kubernetes-service

Verify the plug-in installation by running the following command and checking the list of the plug-ins that are installed.

ibmcloud plugin list

The Red Hat OpenShift on IBM Cloud plug-in is displayed in the results as kubernetes-service.

Initialize the CLI.

ibmcloud oc init

Update the Red Hat OpenShift CLI.

Update the container-registry plugin from the IBM Cloud plug-in repository.

ibmcloud plugin update container-registry

Verify the plug-in installation by running the following command and checking the list of the plug-ins that are installed.

ibmcloud plugin list

The registry plug-in is displayed in the results as container-registry.

Installing the odo CLI for developers

Looking to develop apps without using kubectl system admin commands or YAML configuration files? Check out the Developing on clusters with the Red Hat OpenShift Do CLI tutorial. Uninstalling the CLI

If you no longer need the CLI, you can uninstall it.

This task includes the information for removing these CLIs:

Red Hat OpenShift on IBM Cloud plug-in
IBM Cloud Container Registry plug-in

To uninstall the CLIs:

Uninstall the Red Hat OpenShift on IBM Cloud plug-in.

ibmcloud plugin uninstall kubernetes-service

Uninstall the IBM Cloud Container Registry plug-in.

ibmcloud plugin uninstall container-registry

Verify the plug-ins were uninstalled by running the following command and checking the list of the plug-ins that are installed.

ibmcloud plugin list

The kubernetes-service and the container-registry plug-in are not displayed in the results.

Uninstall the IBM Cloud CLI.

Uninstall the Kubernetes CLI.

sudo rm /usr/local/bin/oc

Using the IBM Cloud Shell in your web browser

IBM® Cloud Shell allows you to use the IBM Cloud CLI and various CLI plug-ins to manage your cluster directly from your web browser.

The IBM Cloud Shell is enabled with several plug-ins and tools, including the base IBM Cloud CLI (ibmcloud), the IBM Cloud Kubernetes Service plug-in (ibmcloud oc), the IBM Cloud Container Registry plug-in (ibmcloud cr), and the Red Hat OpenShift CLI (oc).

While you use the Cloud Shell, keep in mind the following limitations:

You can open up to five concurrent sessions, which operate independently so you can work with different resources, regions, and accounts at once.
Any files that you download and edit locally, such as YAML files, are stored temporarily in the Cloud Shell and don't persist across sessions.
Cloud Shell has a usage quota that limits you to 50 hours within a week.

To launch and use the IBM Cloud Shell:

In the IBM Cloud console menu bar, click the Cloud Shell icon IBM Cloud Shell icon.

A session starts and automatically logs you in to the IBM Cloud CLI with your current account credentials.

Access your cluster by getting the oc login token.
    In the Red Hat OpenShift clusters console, click the cluster that you want to access.
    In the Actions drop-down list, select Connect via CLI.
    Follow the instructions.

If you can't or don't want to open the Red Hat OpenShift console, you can set the cluster context with the --admin option through the CLI with the ibmcloud oc cluster config -c <clusternameor_ID> --admin command.

Properties

Name Value
name openshift CLI
stereotype null
visibility public
isAbstract false
isFinalSpecialization false
isLeaf false
extensionPoints