Tutorial: Connect to an Azure Red Hat OpenShift 4 cluster
In this tutorial, part two of three, you will connect to an Azure Red Hat OpenShift cluster running OpenShift 4 as the kubeadmin user through the OpenShift web console. You learn how to:
- Obtain
kubeadmin
credentials for your cluster - Install the OpenShift CLI
- Connect to an Azure Red Hat OpenShift cluster using the OpenShift CLI
Before you begin
In previous tutorials, an Azure Red Hat OpenShift cluster was created. If you have not done these steps, and would like to follow along, start with Tutorial 1 - Create an Azure Red Hat OpenShift 4 Cluster.
If you choose to install and use the CLI locally, this tutorial requires that you are running the Azure CLI version 2.6.0 or later. Run az --version
to find the version. 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 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
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.
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 -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>
Next steps
In this part of the tutorial, you learned how to:
- Obtain
kubeadmin
credentials for your cluster - Install the OpenShift CLI
- Connect to an Azure Red Hat OpenShift cluster using the OpenShift CLI
Advance to the next tutorial:
Feedback
Submit and view feedback for