Deploy a Microsoft Azure Red Hat OpenShift cluster
In this resource, you’ll learn how to set up your Microsoft Azure Red Hat® OpenShift® environment to deploy your cluster. For this learning path, we will create a public cluster, but you can also create a private cluster. For more information on deploying a private cluster, see “Create an Azure Red Hat OpenShift 4 private cluster” on Microsoft Learn.
What will you learn?
- Setting environment variables and resource groups
- Creating a virtual network with two empty subnets
- Creating your cluster
What do you need before starting?
- Completed all prerequisites
Variables and resource groups
- Sign into the Azure CLI by running
az login
and following the steps to authorize your account. - Set the following environment variables. You can change the values to suit your environment, but these defaults should work.
AZR_RESOURCE_LOCATION=eastus # the location of your cluster AZR_RESOURCE_GROUP=openshift # the name of the resource group where you want to create your cluster AZR_CLUSTER=cluster # the name of your cluster AZR_PULL_SECRET=~/Downloads/pull-secret.txt # the download file of your Red Hat pull secret
- Create an Azure resource group.
az group create \ --name $AZR_RESOURCE_GROUP \ --location $AZR_RESOURCE_LOCATION
Networking
Create a virtual network with two empty subnets.
- Create the virtual network.
az network vnet create \ --address-prefixes 10.0.0.0/22 \ --name "$AZR_CLUSTER-aro-vnet-$AZR_RESOURCE_LOCATION" \ --resource-group $AZR_RESOURCE_GROUP
- Create the control plane subnet.
az network vnet subnet create \ --resource-group $AZR_RESOURCE_GROUP \ --vnet-name "$AZR_CLUSTER-aro-vnet-$AZR_RESOURCE_LOCATION" \ --name "$AZR_CLUSTER-aro-control-subnet-$AZR_RESOURCE_LOCATION" \ --address-prefixes 10.0.0.0/23 \ --service-endpoints Microsoft.ContainerRegistry
- Create the machine subnet.
az network vnet subnet create \ --resource-group $AZR_RESOURCE_GROUP \ --vnet-name "$AZR_CLUSTER-aro-vnet-$AZR_RESOURCE_LOCATION" \ --name "$AZR_CLUSTER-aro-machine-subnet-$AZR_RESOURCE_LOCATION" \ --address-prefixes 10.0.2.0/23 \ --service-endpoints Microsoft.ContainerRegistry
- Disable network policies on the control plane subnet. This is required for the service to be able to connect to and manage the cluster.
az network vnet subnet update \ --name "$AZR_CLUSTER-aro-control-subnet-$AZR_RESOURCE_LOCATION" \ --resource-group $AZR_RESOURCE_GROUP \ --vnet-name "$AZR_CLUSTER-aro-vnet-$AZR_RESOURCE_LOCATION" \ --disable-private-link-service-network-policies true
Create the cluster
This process will take between 30 and 45 minutes to create the cluster.
- Create your cluster.
az aro create \ --resource-group $AZR_RESOURCE_GROUP \ --name $AZR_CLUSTER \ --vnet "$AZR_CLUSTER-aro-vnet-$AZR_RESOURCE_LOCATION" \ --master-subnet "$AZR_CLUSTER-aro-control-subnet-$AZR_RESOURCE_LOCATION" \ --worker-subnet "$AZR_CLUSTER-aro-machine-subnet-$AZR_RESOURCE_LOCATION" \ --pull-secret @$AZR_PULL_SECRET
- Get the OpenShift console URL.
az aro show \ --name $AZR_CLUSTER \ --resource-group $AZR_RESOURCE_GROUP \ -o tsv --query consoleProfile
- Get your OpenShift credentials.
az aro list-credentials \ --name $AZR_CLUSTER \ --resource-group $AZR_RESOURCE_GROUP \ -o tsv
- Use the URL and the credentials provided by the output of the last two commands to log into OpenShift via a web browser. Here, you can monitor and update your cluster as needed.
Once these steps are complete, your cluster is ready for application deployment, which you can do in the OpenShift console or via the CLI.
Next, however, we’ll show you how to delete your cluster and resource group so you aren’t surprised with any unnecessary charges.