In my last post on ARO 4, I have already walk through the steps to set up the Azure environment for creating ARO 4. My 2nd round testing requires the following specific requirements:
Use only one app registration
Not to use pull secret
You will need to complete the session for setting up Azure environment in my previous blog for ARO 4.
Create ARO 4 Cluster with existing service principal
Create a service principal
From the previous test, I learned that the process of creating ARO 4 will create a service principal. I am going to create a service principal before creating cluster.
$ az ad sp create-for-rbac --role Contributor --name all-in-one-sp
This command will return the appId and password information that we will need for the ARO 4 create command later.
Adding API permission to the service principal
Login to Azure Portal
Go to Azure Active Directory
Click App registrations
Click “All applications”
Search for “app-in-one-sp”
Click “View API permission”
Click “Add a permission”
Click “Azure Active Directory Graph”
Click “Delegated Permissions”
Check “User.Read”
Click “Add permission” button at the bottom.
Click “Grant admin consent …”
A green check mark is shown under Status as shown below
Create ARO with existing service principal without pull secret
az aro create \
--resource-group $RESOURCEGROUP \
--name $CLUSTER \
--client-id <service principal application id> \
--client-secret <service principal password> \
--vnet aro-vnet \
--master-subnet master-subnet \
--worker-subnet worker-subnet \
--domain aro.ocpdemo.online
When I opted out the pull secret option, I will get the following message from the output of the azure cli.
No --pull-secret provided: cluster will not include samples or operators from Red Hat or from certified partners.
Adding api and ingress A record to the DNS zone
Using the output from the ARO 4 creation, Use the IP from the “apiserverProfile” portion is for api servier. The IP from “ingressProfiles” is for ingress. The example is shown below.
Test out the ARO cluster
az aro list-credentials \
--name $CLUSTER \
--resource-group $RESOURCEGROUP
Open the following URL from the browser and login using the kubeadmin with password from the above command
I happened to test out ARO 4 with Azure Active Directory integration. The Azure documentation is good, but I had to change a few while testing the steps. I am sharing my experience here and hope someone will find it useful.
Setting the requirements
Install or update Azure CLI
brew update && brew install azure-cli
Make sure you have permission to create resources in the resource group. I logged in as a global administrator when I am testing this.
Setup the environment variables
$ cat aro-env
LOCATION=centralus. # the location of your cluster
RESOURCEGROUP=aro-rg # the name of the resource group where you want to create your cluster
CLUSTER=poc #cluster-id of the ARO 4 cluster
$ source aro-env
Log in Azure
az login
Create a Resource Group
az group create \
--name $RESOURCEGROUP \
--location $LOCATION
Add DNS zone
If you don’t have a DNS zone already, you can use this step.
Login Azure Portal
Type: “DNS Zones” in the search box on the top and click on “DNS Zones”
Click “+Add” on the top
Select the newly created resource group
Enter your domain
Select the location
Create “Review+Create”
Notes:
I am using a domain name outside of the Azure. You will need to add the NS records from the overview page of the DNS zone to your domain.
Request increase of quota from Azure portal. ARO requires a minimum of 40 cores.
Register Resource Provider
az account set --subscription
az provider register -n Microsoft.RedHatOpenShift --wait
az provider register -n Microsoft.Compute --wait
az provider register -n Microsoft.Storage --wait
Once the above steps are done. You don’t have to redo the steps if you are going to reuse the names and resources.
Create Cluster
Please make sure you log in to Azure and environment variables are set.
Information that we need for creating a cluster
Get a copy of the pull secret from cloud.redhat.com. If you don’t have a user name created, please just register as a user for free.
Create an ARO cluster using the following command. Please apply to appropriate values. Some values were used in the example are explained as shown below.
aro-vnet – the name of virtual network
master-subnet – the name of master subnet
worker subnet – the name of worker subnet
./pull-secret.txt – the path and pull secret where is located
aro.ocpdemo.online – custom domain for the cluster
The information from the JSON output of the above command can be useful if you are not familiar with OpenShift 4. You can find your API server IP, API URL, OpenShift console URL and ingress IP. You will need the API, and ingress IP for the next step.
Adding two A records for api and *.apps in the DNS zone
Login to Azure portal
Go to DNS zone
Click onto the domain for the ARO cluster
Click “+ Record Set” on the top menu to create an A record and add values to Name and IP. You will need to repeat this step for both api and *.apps A records.
Name: api or *.apps
IP: the *.apps/ingress IP is from the output of the creation of the ARO
The below screenshot shows the DNS zone configuration and adding 2 A records.
Test ARO Cluster
Getting Kubeadmin credential
az aro list-credentials \
--name $CLUSTER \
--resource-group $RESOURCEGROUP
The command will return the kubeadmin credential.
Log in OpenShift Console
Open a browser and go to the OpenShift console or look for “consoleProfile” from the JSON output from ARO creation
The clientSecret is using the secret (openid-client-secret-azuread) that you created from the previous step.
Alternatively, you can obtain the clientID and tenant id from Azure Portal.
Login Azure Portal
Click Home
Click Azure Active Directory
Click App registrations on the left menu
Click all applications tab
Type the application that you just created in the search area
Click onto the application (my application is poc-aro-auth)
Under Overview, the information is shown as “Application (client) ID” and Directory (tenant) ID” as in the image below.
Update OpenShift OAuth Configuration
oc apply -f openid.yaml
Login OpenShift console via AAD
It will redirect you to Azure login page
Troubeshoot
Tip #1: If you are getting error, you can login as kubeadmin and check the logs from oauth-openshift pods under openshift-authentication project.
Tip #2: if you are creating a new registered application to try, make sure you clean up the user and identity.