You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/openshift/howto-create-service-principal.md
+36-56Lines changed: 36 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,55 +18,34 @@ To interact with Azure APIs, an Azure Red Hat OpenShift cluster requires an Azur
18
18
19
19
This article explains how to create and use a service principal for your Azure Red Hat OpenShift clusters using the Azure command-line interface (Azure CLI) or the Azure portal.
20
20
21
-
## Before you begin
22
-
23
-
The user creating an Azure AD service principal must have permissions to register an application with your Azure AD tenant and to assign the application to a role in your subscription. You need **User Access Administrator** and **Contributor** permissions at the resource-group level to create service principals.
24
-
25
-
Use the following Azure CLI command to add these permissions.
26
-
27
-
```azurecli-interactive
28
-
az role assignment create \
29
-
--role 'User Access Administrator' \
30
-
--assignee-object-id $SP_OBJECT_ID \
31
-
--resource-group $RESOURCEGROUP \
32
-
--assignee-principal-type 'ServicePrincipal'
33
-
34
-
az role assignment create \
35
-
--role 'Contributor' \
36
-
--assignee-object-id $SP_OBJECT_ID \
37
-
--resource-group $RESOURCEGROUP \
38
-
--assignee-principal-type 'ServicePrincipal'
39
-
```
40
-
41
-
If you don't have the required permissions, you can ask your Azure AD or subscription administrator to assign them. Alternatively, your Azure AD or subscription administrator can create a service principal in advance for you to use with the Azure Red Hat OpenShift cluster.
42
-
43
-
If you're using a service principal from a different Azure AD tenant, there are more considerations regarding the permissions available when you deploy the cluster. For example, you may not have the appropriate permissions to read and write directory information.
44
-
45
-
For more information on user roles and permissions, see [What are the default user permissions in Azure Active Directory?](../active-directory/fundamentals/users-default-permissions.md).
46
-
47
21
> [!NOTE]
48
22
> Service principals expire in one year unless configured for longer periods. For information on extending your service principal expiration period, see [Rotate service principal credentials for your Azure Red Hat OpenShift (ARO) Cluster](howto-service-principal-credential-rotation.md).
49
23
50
24
::: zone pivot="aro-azurecli"
51
25
52
26
## Create a service principal with Azure CLI
53
27
54
-
The following sections explain how to use the Azure CLI to create a service principal for your Azure Red Hat OpenShift cluster.
28
+
The following sections explain how to use the Azure CLI to create a service principal for your Azure Red Hat OpenShift cluster
55
29
56
30
## Prerequisite
57
31
58
32
If you’re using the Azure CLI, you’ll need Azure CLI version 2.0.59 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli).
59
33
34
+
## Create a resource group
60
35
61
-
## Create a service principal - Azure CLI
36
+
```azurecli-interactive
37
+
AZ_RG=$(az group create -n test-aro-rg -l eastus2 --query name -o tsv)
38
+
```
62
39
63
-
To create a service principal with the Azure CLI, run the `az ad sp create-for-rbac` command.
40
+
## Create a service principal - Azure CLI
64
41
65
-
> [!NOTE]
66
-
> When using a service principal to create a new cluster, you may need to assign a Contributor role here.
42
+
To create a service principal with the Azure CLI, run the following command.
67
43
68
-
```azure-cli
69
-
az ad sp create-for-rbac --name myAROClusterServicePrincipal
44
+
```azurecli-interactive
45
+
# Get Azure subscription ID
46
+
AZ_SUB_ID=$(az account show --query id -o tsv)
47
+
# Create a service principal with contributor role and scoped to the ARO resource group
48
+
az ad sp create-for-rbac -n "test-aro-SP" --role contributor --scopes "/subscriptions/${AZ_SUB_ID}/resourceGroups/${AZ_RG}"
70
49
```
71
50
72
51
The output is similar to the following example.
@@ -80,26 +59,21 @@ The output is similar to the following example.
80
59
81
60
"name": "http://myAROClusterServicePrincipal",
82
61
83
-
"password": "",
62
+
"password": "yourpassword",
84
63
85
-
"tenant": ""
64
+
"tenant": "yourtenantname" t
86
65
87
66
}
88
67
```
89
68
90
69
Retain your `appId` and `password`. These values are used when you create an Azure Red Hat OpenShift cluster below.
70
+
71
+
> [!NOTE]
72
+
> This service principal only allows a contributor over the resource group the ARO cluster is located in. If your VNet is in another resource group, you need to assign the service principal contributor role to that resource group as well.
91
73
92
-
## Grant permissions to the service principal - Azure CLI
93
-
94
-
Grant permissions to an existing service principal with Azure CLI, as shown in the following command.
74
+
For more information, see [Manage service principal roles](/cli/azure/create-an-azure-service-principal-azure-cli#3-manage-service-principal-roles).
95
75
96
-
```azurecli-interactive
97
-
az role assignment create \
98
-
--role 'Contributor' \
99
-
--assignee-object-id $SP_OBJECT_ID \
100
-
--resource-group $RESOURCEGROUP \
101
-
--assignee-principal-type 'ServicePrincipal'
102
-
```
76
+
To grant permissions to an existing service principal with the Azure portal, see [Create an Azure AD app and service principal in the portal](../active-directory/develop/howto-create-service-principal-portal.md#configure-access-policies-on-resources).
103
77
104
78
## Use the service principal to create a cluster - Azure CLI
105
79
@@ -128,21 +102,17 @@ az aro create \
128
102
129
103
The following sections explain how to use the Azure portal to create a service principal for your Azure Red Hat OpenShift cluster.
130
104
131
-
## Create a service principal - Azure portal
105
+
## Create a service principal - Azure portal
132
106
133
-
To create a service principal using the Azure portal, see [Create an Azure AD app and service principal in the portal](../active-directory/develop/howto-create-service-principal-portal.md).
134
-
135
-
## Grant permissions to the service principal - Azure portal
136
-
137
-
To grant permissions to an existing service principal with the Azure portal, see [Create an Azure AD app and service principal in the portal](../active-directory/develop/howto-create-service-principal-portal.md#configure-access-policies-on-resources).
107
+
To create a service principal using the Azure portal, complete the following steps.
138
108
139
-
## Use the service principal - Azure portal
109
+
1. On the Create Azure Red Hat OpenShift **Basics** tab, create a resource group for your subscription, as shown in the following example.
140
110
141
-
When deploying an Azure Red Hat OpenShift cluster using the Azure portal, configure the service principal on the **Authentication** page of the **Azure Red Hat OpenShift** dialog.
111
+
:::image type="content" source="./media/basics-openshift-sp.png" alt-text="Screenshot that shows how to use the Azure Red Hat service principal with Azure portal to create a cluster." lightbox="./media/basics-openshift-sp.png":::
142
112
143
-
:::image type="content" source="./media/openshift-service-principal-portal.png" alt-text="Screenshot that shows how to use the Azure Red Hat service principal with Azure portal to create a cluster." lightbox="./media/openshift-service-principal-portal.png":::
113
+
2. Click **Next: Authentication**to configure and deploy the service principal on the **Authentication** page of the **Azure Red Hat OpenShift** dialog.
144
114
145
-
Specify the following values, and then select **Review + Create**.
115
+
:::image type="content" source="./media/openshift-service-principal-portal.png" alt-text="Screenshot that shows how to use the Authentication tab with Azure portal to create a service principal." lightbox="./media/openshift-service-principal-portal.png":::
146
116
147
117
In the **Service principal information** section:
148
118
@@ -151,5 +121,15 @@ In the **Service principal information** section:
151
121
152
122
In the **Cluster pull secret** section:
153
123
154
-
-**Pull secret** is your cluster's pull secret's decrypted value.
124
+
-**Pull secret** is your cluster's pull secret's decrypted value. If you don't have a pull secret, leave this field blank.
125
+
126
+
After completing this tab, select **Next: Networking** to continue creating your cluster. Select **Review + Create** when you complete the remaining tabs.
127
+
128
+
> [!NOTE]
129
+
> This service principal only allows a contributor over the resource group the Azure Red Hat OpenShift cluster is located in. If your VNet is in another resource group, you need to assign the service principal contributor role to that resource group as well.
130
+
131
+
## Grant permissions to the service principal - Azure portal
132
+
133
+
To grant permissions to an existing service principal with the Azure portal, see [Create an Azure AD app and service principal in the portal](../active-directory/develop/howto-create-service-principal-portal.md#configure-access-policies-on-resources).
0 commit comments