Share via


Quickstart: Connect to an Azure Red Hat OpenShift 4 cluster

In this Quickstart, you learn how to connect to a Microsoft Azure Red Hat OpenShift cluster running OpenShift 4 with the kubeadmin user through the OpenShift web console.

Prerequisites

This article requires Azure CLI version 2.6.0 or later. To find the version, run the az --version command. If you need to install or upgrade, see Install Azure CLI.

Connect to the cluster

You can log into the cluster using the kubeadmin user. Run the following command to get the kubeadmin user's password.

Create variables for your cluster name and resource group name. Replace <resourceGroupName> and <clusterName> with your cluster's values.

RESOURCEGROUP=<resourceGroupName>
CLUSTER=<clusterName>
az aro list-credentials \
  --name $CLUSTER \
  --resource-group $RESOURCEGROUP

The following example output shows the password in kubeadminPassword.

{
  "kubeadminPassword": "<generated password>",
  "kubeadminUsername": "kubeadmin"
}

You can find the cluster console URL by running the following command, and outputs a URL like https://console-openshift-console.apps.<random>.<region>.aroapp.io/.

az aro show \
  --name $CLUSTER \
  --resource-group $RESOURCEGROUP \
  --query "consoleProfile.url" --output tsv

Launch the console URL in a browser and sign in using the kubeadmin credentials.

Install the OpenShift CLI

After you're logged into the OpenShift Web Console, select the ? at the top right and then on Command Line Tools. Download the release appropriate to your machine.

Screenshot that highlights the Command Line Tools option in the list when you select the question mark icon.

You can also download the latest release of the CLI appropriate to your machine.

If you're running the commands on the Azure Cloud Shell, download the latest OpenShift 4 CLI for Linux.

cd ~
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz

mkdir openshift
tar -zxvf openshift-client-linux.tar.gz -C openshift
echo 'export PATH=$PATH:~/openshift' >> ~/.bashrc && source ~/.bashrc

Connect using the OpenShift CLI

Retrieve the API server's address.

apiServer=$(az aro show --resource-group $RESOURCEGROUP --name $CLUSTER --query apiserverProfile.url --output tsv)

Create the kubevar variable that stores the value of kubeadminPassword so that you don't need to type or copy and paste the credential.

kubevar=$(az aro list-credentials --name $CLUSTER --resource-group $RESOURCEGROUP --query kubeadminPassword --output tsv)

Sign in to the OpenShift cluster's API server using the following command.

oc login $apiServer --username kubeadmin --password $kubevar

After you sign in you should clear the kubevar variable's value.

kubevar=""

Next steps