Connect to OpenShift cluster on Azure
This section describes how to connect to an OpenShift cluster on Azure.
Connect to an Azure Red Hat OpenShift 4 cluster
The section below describes how to connect to an OpenShift 4 cluster. Complete details can be found at: Microsoft documentation - connecting to a cluster
Example using: Ubuntu 20.04
Connect to the cluster
If you not set environment variables before, do it :
export LOCATION=eastus # the location of your clusterexport RESOURCEGROUP=aro-rg # the name of the resource group where you want to create your clusterexport CLUSTER=cluster # the name of your cluster
You can log into the cluster using the kubeadmin user. Run the following command to find the password for the kubeadmin user.
az aro list-credentials \--name $CLUSTER \--resource-group $RESOURCEGROUP
The following example output shows what the password will be in kubeadminPassword.
{"kubeadminPassword": "<generated password>","kubeadminUsername": "kubeadmin"}
You can find the cluster console URL by running the following command, which will look like https://console-openshift-console.apps.<random>.<region>.aroapp.io/.
az aro show \--name $CLUSTER \--resource-group $RESOURCEGROUP \--query "consoleProfile.url" -o tsv
Launch the console URL in a browser and login using the kubeadmin credentials.
Install the OpenShift CLI
Complete details can be found at Microsoft documentation
Once you're logged into the OpenShift Web Console, click on the ?
on the top right and then on Command Line Tools. Download the release appropriate to your machine.
You can also download the latest release of the CLI appropriate to your machine from https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/
.
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.gzmkdir openshifttar -zxvf openshift-client-linux.tar.gz -C openshiftecho 'export PATH=$PATH:~/openshift' >> ~/.bashrc && source ~/.bashrc
Connect using the OpenShift CLI
You can get kubeadmin password and cluster URL by (Don't forget set variables before CLUSTER
and RESOURCEGROUP
):
az aro list-credentials \--name $CLUSTER \--resource-group $RESOURCEGROUPaz aro show \--name $CLUSTER \--resource-group $RESOURCEGROUP \--query "consoleProfile.url" -o tsv
Retrieve the API server's address.
export apiServer=$(az aro show -g $RESOURCEGROUP -n $CLUSTER --query apiserverProfile.url -o tsv)
Login to the OpenShift cluster's API server using the following command. Replace <kubeadmin password>
with the password you just retrieved.
oc login $apiServer -u kubeadmin -p <kubeadmin password>