|
| 1 | +--- |
| 2 | +title: Connect to an Azure Red Hat OpenShift 4 cluster |
| 3 | +description: Learn how to connect a Microsoft Azure Red Hat OpenShift cluster |
| 4 | +author: johnmarco |
| 5 | +ms.author: johnmarc |
| 6 | +ms.topic: article |
| 7 | +ms.service: azure-redhat-openshift |
| 8 | +ms.date: 06/12/2024 |
| 9 | +#Customer intent: As a developer, I want learn how to create an Azure Red Hat OpenShift cluster, scale it, and then clean up resources so that I am not charged for what I'm not using. |
| 10 | +--- |
| 11 | + |
| 12 | +# Connect to an Azure Red Hat OpenShift 4 cluster |
| 13 | + |
| 14 | +This article shows you how to connect to an Azure Red Hat OpenShift cluster running OpenShift 4 as the kubeadmin user through the OpenShift web console. |
| 15 | + |
| 16 | +## Before you begin |
| 17 | + |
| 18 | +This article requires 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](/cli/azure/install-azure-cli). |
| 19 | + |
| 20 | +## Connect to the cluster |
| 21 | + |
| 22 | +You can log into the cluster using the `kubeadmin` user. Run the following command to find the password for the `kubeadmin` user. |
| 23 | + |
| 24 | +```azurecli-interactive |
| 25 | +az aro list-credentials \ |
| 26 | + --name $CLUSTER \ |
| 27 | + --resource-group $RESOURCEGROUP |
| 28 | +``` |
| 29 | + |
| 30 | +The following example output shows the password in `kubeadminPassword`. |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "kubeadminPassword": "<generated password>", |
| 35 | + "kubeadminUsername": "kubeadmin" |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +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/`. |
| 40 | + |
| 41 | +```azurecli-interactive |
| 42 | + az aro show \ |
| 43 | + --name $CLUSTER \ |
| 44 | + --resource-group $RESOURCEGROUP \ |
| 45 | + --query "consoleProfile.url" -o tsv |
| 46 | +``` |
| 47 | + |
| 48 | +Launch the console URL in a browser and login using the `kubeadmin` credentials. |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +## Install the OpenShift CLI |
| 53 | + |
| 54 | +Once 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. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +You can also download the [latest release of the CLI](https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/) appropriate to your machine. |
| 59 | + |
| 60 | +If you're running the commands on the Azure Cloud Shell, download the latest OpenShift 4 CLI for Linux. |
| 61 | + |
| 62 | +```azurecli-interactive |
| 63 | +cd ~ |
| 64 | +wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz |
| 65 | +
|
| 66 | +mkdir openshift |
| 67 | +tar -zxvf openshift-client-linux.tar.gz -C openshift |
| 68 | +echo 'export PATH=$PATH:~/openshift' >> ~/.bashrc && source ~/.bashrc |
| 69 | +``` |
| 70 | + |
| 71 | +## Connect using the OpenShift CLI |
| 72 | + |
| 73 | +Retrieve the API server's address. |
| 74 | + |
| 75 | +```azurecli-interactive |
| 76 | +apiServer=$(az aro show -g $RESOURCEGROUP -n $CLUSTER --query apiserverProfile.url -o tsv) |
| 77 | +``` |
| 78 | + |
| 79 | +Login to the OpenShift cluster's API server using the following command. Replace **\<kubeadmin password>** with the password you retrieved. |
| 80 | + |
| 81 | +```azurecli-interactive |
| 82 | +oc login $apiServer -u kubeadmin -p <kubeadmin password> |
| 83 | +``` |
| 84 | + |
| 85 | +## Next steps |
| 86 | + |
| 87 | +Learn how to [delete an Azure Red Hat OpenShift cluster](delete-cluster.md). |
0 commit comments