Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this quickstart, you connect to an Azure Red Hat OpenShift with hosted control planes (HCP) cluster by requesting a temporary administrative credential.
The credential generates a kubeconfig file that you use with the OpenShift CLI (oc) to access the cluster.
Prerequisites
- Azure CLI version 2.67.0 or later. To find the version, run
az --version. If you need to install or upgrade, see Install Azure CLI. - A deployed Azure Red Hat OpenShift with hosted control planes cluster. If you don't have one, see Create an Azure Red Hat OpenShift with hosted control planes cluster.
- The OpenShift CLI (
oc). To install, see the OpenShift CLI documentation.
Important
If your cluster has a private API server, you must run all commands in this article from a host that has private network connectivity to the cluster's virtual network. You can establish connectivity through Azure VNet peering, Azure VPN Gateway, or Azure ExpressRoute. To quickly test connectivity, see Connect from a jump box VM.
Create a jump box VM (private clusters only)
If your cluster has a private API server and you don't have an existing private network connection, you can create a jump box virtual machine in a dedicated subnet with its own NSG. Use a jump box VM for initial cluster setup, testing, or one-time administrative tasks. For ongoing production access from on-premises networks or CI/CD pipelines, use Azure VPN Gateway or Azure ExpressRoute instead.
Prepare your environment
Set the environment variables. Replace the placeholder values with your own values.
LOCATION="<location>" CUSTOMER_RG_NAME="<resource-group-name>" JUMPBOX_SUBNET_NAME="<subnet-name>" JUMPBOX_NSG_NAME="<nsg-name>" JUMPBOX_NAME="<jumpbox-vm-name>"Create a dedicated NSG for the jump box VM.
az network nsg create \ --name "${JUMPBOX_NSG_NAME}" \ --resource-group "${CUSTOMER_RG_NAME}" \ --location "${LOCATION}"Add an inbound SSH rule restricted to your desired IP or CIDR range.
az network nsg rule create \ --resource-group "${CUSTOMER_RG_NAME}" \ --nsg-name "${JUMPBOX_NSG_NAME}" \ --name "AllowSSH" \ --priority 1000 \ --protocol Tcp \ --destination-port-ranges 22 \ --source-address-prefixes "<source-ip-address>" \ --access Allow \ --direction InboundReplace
<source-ip-address>with your desired source.Create a dedicated jump box VM subnet.
az network vnet subnet create \ --name "${JUMPBOX_SUBNET_NAME}" \ --vnet-name "${CUSTOMER_VNET_NAME}" \ --resource-group "${CUSTOMER_RG_NAME}" \ --address-prefixes 10.0.2.0/28 \ --network-security-group "${JUMPBOX_NSG_NAME}"
Create the jump box VM
Create the jump box VM.
az vm create \ --resource-group "${CUSTOMER_RG_NAME}" \ --name "${JUMPBOX_NAME}" \ --image Ubuntu2204 \ --admin-username azureuser \ --vnet-name "${CUSTOMER_VNET_NAME}" \ --subnet "${JUMPBOX_SUBNET_NAME}" \ --size Standard_B2s \ --generate-ssh-keysGet the jump box VM public IP address.
JUMPBOX_IP=$(az vm show \ --resource-group "${CUSTOMER_RG_NAME}" \ --name "${JUMPBOX_NAME}" \ --show-details \ --query publicIps \ --output tsv) echo "Jump box VM IP: ${JUMPBOX_IP}"Connect to the jump box VM over SSH.
ssh azureuser@"${JUMPBOX_IP}"
Set up the jump box VM environment
Because the private cluster's API server has no public endpoint, you must run oc commands from within the virtual network.
Download and install the Azure CLI in the jump box VM.
This example downloads and installs the Azure CLI for Ubuntu. If you created the jump box with a different operating system, follow the Azure CLI Azure CLI installation instructions for your OS.
curl -fsSL 'https://azurecliprod.blob.core.windows.net/$root/deb_install.sh' | sudo bashVerify that the Azure CLI is installed.
az versionSign in to Azure.
az loginThis command returns a device code and URL.
Open the URL in a browser on your local machine, enter the code, and authenticate.
Download the ARO HCP CLI extension.
curl -sL https://aka.ms/aro-hcp-cli -o aro_hcp-1.0.0b3-py3-none-any.whlAdd the ARO HCP CLI extension.
az extension add --source aro_hcp-1.0.0b3-py3-none-any.whlVerify that the ARO HCP CLI extension is installed.
az aro hcp -hInstall the OpenShift CLI.
curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz \ | sudo tar -C /usr/local/bin -xz oc kubectlVerify that the OpenShift CLI is installed.
oc version --client
Connect to the cluster
Administrative credentials expire after 24 hours.
Set the following environment variables if you didn't already set them. Replace the placeholder values with the values for your cluster.
CUSTOMER_RG_NAME="<resource-group-name>" CLUSTER_NAME="<cluster-name>"Request a temporary administrative credential for the cluster and save the
kubeconfigto a file.az aro hcp cluster request-credential --admin \ --name "${CLUSTER_NAME}" \ --resource-group "${CUSTOMER_RG_NAME}" \ --file kubeconfigSet the
KUBECONFIGenvironment variable to the path of thekubeconfigfile you saved.export KUBECONFIG=kubeconfigVerify that you can connect to the cluster.
oc auth whoamiThe following example output shows a successful connection.
ATTRIBUTE VALUE Username system:customer-break-glass:<user-id> Groups [system:masters system:authenticated] Extra: authentication.kubernetes.io/credential-id <credential-id>
Clean up
Revoke administrative credentials
If you want to revoke all administrative credentials for the cluster, run the following command.
az aro hcp cluster revoke-credential \
--name "${CLUSTER_NAME}" \
--resource-group "${CUSTOMER_RG_NAME}"
Delete the jump box VM
If you created a jump box VM to connect to a private cluster, delete the VM to avoid ongoing charges.
az vm delete \
--resource-group "${CUSTOMER_RG_NAME}" \
--name "${JUMPBOX_NAME}" \
--yes