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
title: "Azure RBAC on Azure Arc-enabled Kubernetes clusters (preview)"
3
-
ms.date: 05/04/2023
2
+
title: "Azure RBAC on Azure Arc-enabled Kubernetes clusters"
3
+
ms.date: 05/22/2024
4
4
ms.topic: how-to
5
5
ms.custom: devx-track-azurecli
6
6
description: "Use Azure RBAC for authorization checks on Azure Arc-enabled Kubernetes clusters."
7
7
---
8
8
9
-
# Use Azure RBAC on Azure Arc-enabled Kubernetes clusters (preview)
9
+
# Use Azure RBAC on Azure Arc-enabled Kubernetes clusters
10
10
11
11
Kubernetes [ClusterRoleBinding and RoleBinding](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#rolebinding-and-clusterrolebinding) object types help to define authorization in Kubernetes natively. By using this feature, you can use Microsoft Entra ID and role assignments in Azure to control authorization checks on the cluster. Azure role assignments let you granularly control which users can read, write, and delete Kubernetes objects such as deployment, pod, and service.
12
12
13
13
For a conceptual overview of this feature, see [Azure RBAC on Azure Arc-enabled Kubernetes](conceptual-azure-rbac.md).
14
14
15
-
[!INCLUDE [preview features note](./includes/preview/preview-callout.md)]
16
-
17
15
## Prerequisites
18
16
19
17
-[Install or upgrade the Azure CLI](/cli/azure/install-azure-cli) to the latest version.
@@ -37,222 +35,31 @@ For a conceptual overview of this feature, see [Azure RBAC on Azure Arc-enabled
37
35
> [!NOTE]
38
36
> You can't set up this feature for Red Hat OpenShift, or for managed Kubernetes offerings of cloud providers like Elastic Kubernetes Service or Google Kubernetes Engine where the user doesn't have access to the API server of the cluster. For Azure Kubernetes Service (AKS) clusters, this [feature is available natively](../../aks/manage-azure-rbac.md) and doesn't require the AKS cluster to be connected to Azure Arc.
39
37
40
-
<a name='set-up-azure-ad-applications'></a>
41
-
42
-
## Set up Microsoft Entra applications
43
-
44
-
### [Azure CLI >= v2.3.7](#tab/AzureCLI)
45
-
46
-
#### Create a server application
47
-
48
-
1. Create a new Microsoft Entra application and get its `appId` value. This value is used in later steps as `serverApplicationId`.
1. To grant "Sign in and read user profile" API permissions to the server application, copy this JSON and save it in a file called oauth2-permissions.json:
59
-
60
-
```json
61
-
{
62
-
"oauth2PermissionScopes": [
63
-
{
64
-
"adminConsentDescription": "Sign in and read user profile",
65
-
"adminConsentDisplayName": "Sign in and read user profile",
66
-
"id": "<paste_the_SERVER_APP_ID>",
67
-
"isEnabled": true,
68
-
"type": "User",
69
-
"userConsentDescription": "Sign in and read user profile",
70
-
"userConsentDisplayName": "Sign in and read user profile",
71
-
"value": "User.Read"
72
-
}
73
-
]
74
-
}
75
-
```
76
-
77
-
1. Update the application's group membership claims. Run the commands in the same directory as the `oauth2-permissions.json` file. RBAC for Azure Arc-enabled Kubernetes requires [`signInAudience` to be set to **AzureADMyOrg**](../../active-directory/develop/supported-accounts-validation.md):
78
-
79
-
```azurecli
80
-
az ad app update --id "${SERVER_APP_ID}" --set groupMembershipClaims=All
1. Create a service principal and get its `password` field value. This value is required later as `serverApplicationSecret` when you're enabling this feature on the cluster. This secret is valid for one year by default and will need to be [rotated after that](#refresh-the-secret-of-the-server-application). To set a custom expiration duration, use [`az ad sp credential reset`](/cli/azure/ad/sp/credential?view=azure-cli-latest&preserve-view=true#az-ad-sp-credential-reset):
1. Grant "Sign in and read user profile" API permissions to the application by using [`az ad app permission`](/cli/azure/ad/app/permission?view=azure-cli-latest&preserve-view=true##az-ad-app-permission-add-examples):
95
-
96
-
```azurecli
97
-
az ad app permission add --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --api-permissions e1fe6dd8-ba31-4d61-89e7-88639da4683d=Scope
98
-
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --scope User.Read
99
-
```
100
-
101
-
> [!NOTE]
102
-
> An Azure [application administrator](../../active-directory/roles/permissions-reference.md#application-administrator) has to run this step.
103
-
>
104
-
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
105
-
106
-
#### Create a client application
107
-
108
-
1. Create a new Microsoft Entra application and get its `appId` value. This value is used in later steps as `clientApplicationId`.
2. Create a service principal for this client application:
117
-
118
-
```azurecli
119
-
az ad sp create --id "${CLIENT_APP_ID}"
120
-
```
121
-
122
-
3. Get the `oAuthPermissionId` value for the server application:
123
-
124
-
```azurecli
125
-
az ad app show --id "${SERVER_APP_ID}" --query "api.oauth2PermissionScopes[0].id" -o tsv
126
-
```
127
-
128
-
4. Grant the required permissions for the client application. RBAC for Azure Arc-enabled Kubernetes requires [`signInAudience` to be set to **AzureADMyOrg**](../../active-directory/develop/supported-accounts-validation.md):
129
-
130
-
```azurecli
131
-
az ad app permission add --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}" --api-permissions <oAuthPermissionId>=Scope
132
-
RESOURCE_APP_ID=$(az ad app show --id "${CLIENT_APP_ID}" --query "requiredResourceAccess[0].resourceAppId" -o tsv)
133
-
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${RESOURCE_APP_ID}" --scope User.Read
134
-
az ad app update --id ${CLIENT_APP_ID} --set signInAudience=AzureADMyOrg
135
-
CLIENT_OBJECT_ID=$(az ad app show --id "${CLIENT_APP_ID}" --query "id" -o tsv)
1. Update the application's group membership claims:
154
-
155
-
```azurecli
156
-
az ad app update --id "${SERVER_APP_ID}" --set groupMembershipClaims=All
157
-
```
158
-
159
-
1. Create a service principal and get its `password` field value. This value is required later as `serverApplicationSecret` when you're enabling this feature on the cluster. This secret is valid for one year by default and will need to be [rotated after that](#refresh-the-secret-of-the-server-application). To set a custom expiration duration, use [`az ad sp credential reset`](/cli/azure/ad/sp/credential?view=azure-cli-latest&preserve-view=true#az-ad-sp-credential-reset):
1. Grant "Sign in and read user profile" API permissions to the application by using [`az ad app permission`](/cli/azure/ad/app/permission?view=azure-cli-latest&preserve-view=true##az-ad-app-permission-add-examples):
167
-
168
-
```azurecli
169
-
az ad app permission add --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000 --api-permissions e1fe6dd8-ba31-4d61-89e7-88639da4683d=Scope
170
-
az ad app permission grant --id "${SERVER_APP_ID}" --api 00000003-0000-0000-c000-000000000000
171
-
```
172
-
173
-
> [!NOTE]
174
-
> An Azure [application administrator](../../active-directory/roles/permissions-reference.md#application-administrator) has to run this step.
175
-
>
176
-
> For usage of this feature in production, we recommend that you create a different server application for every cluster.
177
-
178
-
#### Create a client application
38
+
## Enable Azure RBAC on the cluster
179
39
180
-
1. Create a new Microsoft Entra application and get its `appId` value. This value is used in later steps as `clientApplicationId`.
40
+
1. Get the cluster MSI identity by running the following command:
az connectedk8s show -g <resource-group> -n <connected-cluster-name>
186
44
```
187
45
188
-
2. Create a service principal for this client application:
46
+
1. Get the ED (`identity.principalId`) from the output and run the following command to assign the **Connected Cluster Managed Identity CheckAccess Reader** role to the cluster MSI:
189
47
190
48
```azurecli
191
-
az ad sp create --id "${CLIENT_APP_ID}"
49
+
az role assignment create --role "Connected Cluster Managed Identity CheckAccess Reader" --assignee "<Cluster MSI ID>" --scope <cluster ARM ID>
192
50
```
193
51
194
-
3. Get the `oAuthPermissionId` value for the server application:
195
52
196
-
```azurecli
197
-
az ad app show --id "${SERVER_APP_ID}" --query "oauth2Permissions[0].id" -o tsv
198
-
```
199
-
200
-
4. Grant the required permissions for the client application:
53
+
1. Enable Azure role-based access control (RBAC) on your Azure Arc-enabled Kubernetes cluster by running the following command:
201
54
202
55
```azurecli
203
-
az ad app permission add --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}" --api-permissions <oAuthPermissionId>=Scope
204
-
az ad app permission grant --id "${CLIENT_APP_ID}" --api "${SERVER_APP_ID}"
205
-
```
206
-
207
-
---
208
-
209
-
## Create a role assignment for the server application
210
-
211
-
The server application needs the `Microsoft.Authorization/*/read` permissions so that it can confirm that the user making the request is authorized on the Kubernetes objects that are included in the request.
212
-
213
-
1. Create a file named *accessCheck.json* with the following contents:
> Before you run the preceding command, ensure that the `kubeconfig` file on the machine is pointing to the cluster on which you'll enable the Azure RBAC feature.
254
-
>
255
-
> Use `--skip-azure-rbac-list` with the preceding command for a comma-separated list of usernames, emails, and OpenID connections undergoing authorization checks by using Kubernetes native `ClusterRoleBinding` and `RoleBinding` objects instead of Azure RBAC.
59
+
> [!NOTE]
60
+
> Before you run the preceding command, ensure that the `kubeconfig` file on the machine is pointing to the cluster on which you'll enable the Azure RBAC feature.
61
+
>
62
+
> Use `--skip-azure-rbac-list` with the preceding command for a comma-separated list of usernames, emails, and OpenID connections undergoing authorization checks by using Kubernetes native `ClusterRoleBinding` and `RoleBinding` objects instead of Azure RBAC.
256
63
257
64
### Generic cluster where no reconciler is running on the `apiserver` specification
258
65
@@ -487,7 +294,7 @@ Using a shared kubeconfig requires slightly different steps depending on your Ku
487
294
488
295
### [Kubernetes version >= 1.26](#tab/kubernetes-latest)
489
296
490
-
1. Run the following command to set the credentials for the user:
297
+
1. Run the following command to set the credentials for the user. Specify `serverApplicationId` as `6256c85f-0aad-4d50-b960-e6e9b21efe35` and `clientApplicationId` as `3f4439ff-e698-4d6d-84fe-09c9d574f06b`:
@@ -519,10 +326,10 @@ Using a shared kubeconfig requires slightly different steps depending on your Ku
519
326
name: azure
520
327
```
521
328
522
-
> [!NOTE]
523
-
>[Exec plugin](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins) is a Kubernetes authentication strategy that allows `kubectl` to execute an external command to receive user credentials to send to `apiserver`. Starting with Kubernetes version 1.26, the default Azure authorization plugin is no longer included in `client-go` and `kubectl`. With later versions, in order to use the exec plugin to receive user credentials you must use [Azure Kubelogin](https://azure.github.io/kubelogin/index.html), a `client-go` credential (exec) plugin that implements Azure authentication.
329
+
> [!NOTE]
330
+
>[Exec plugin](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins) is a Kubernetes authentication strategy that allows `kubectl` to execute an external command to receive user credentials to send to `apiserver`. Starting with Kubernetes version 1.26, the default Azure authorization plugin is no longer included in `client-go` and `kubectl`. With later versions, in order to use the exec plugin to receive user credentials you must use [Azure Kubelogin](https://azure.github.io/kubelogin/index.html), a `client-go` credential (exec) plugin that implements Azure authentication.
524
331
525
-
4. Install Azure Kubelogin:
332
+
1. Install Azure Kubelogin:
526
333
527
334
- For Windows or Mac, follow the [Azure Kubelogin installation instructions](https://azure.github.io/kubelogin/install.html#installation).
528
335
- For Linux or Ubuntu, download the [latest version of kubelogin](https://github.com/Azure/kubelogin/releases), then run the following commands:
@@ -537,7 +344,7 @@ Using a shared kubeconfig requires slightly different steps depending on your Ku
537
344
sudo chmod +x /usr/local/bin/kubelogin
538
345
```
539
346
540
-
5. [Convert](https://azure.github.io/kubelogin/cli/convert-kubeconfig.html) the kubelogin to use the appropriate [login mode](https://azure.github.io/kubelogin/concepts/login-modes.html). For example, for [device code login](https://azure.github.io/kubelogin/concepts/login-modes/devicecode.html) with a Microsoft Entra user, the commands would be as follows:
347
+
1. [Convert](https://azure.github.io/kubelogin/cli/convert-kubeconfig.html) the kubelogin to use the appropriate [login mode](https://azure.github.io/kubelogin/concepts/login-modes.html). For example, for [device code login](https://azure.github.io/kubelogin/concepts/login-modes/devicecode.html) with a Microsoft Entra user, the commands would be as follows:
541
348
542
349
```bash
543
350
export KUBECONFIG=/path/to/kubeconfig
@@ -547,7 +354,7 @@ Using a shared kubeconfig requires slightly different steps depending on your Ku
547
354
548
355
### [Kubernetes < v1.26](#tab/Kubernetes-earlier)
549
356
550
-
1. Run the following command to set the credentials for the user:
357
+
1. Run the following command to set the credentials for the user. Specify `serverApplicationId` as `6256c85f-0aad-4d50-b960-e6e9b21efe35` and `clientApplicationId` as `3f4439ff-e698-4d6d-84fe-09c9d574f06b`:
Copy file name to clipboardExpand all lines: articles/azure-arc/kubernetes/conceptual-azure-rbac.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,14 @@
1
1
---
2
-
title: "Azure RBAC on Azure Arc-enabled Kubernetes (preview)"
3
-
ms.date: 02/28/2024
2
+
title: "Azure RBAC on Azure Arc-enabled Kubernetes"
3
+
ms.date: 05/22/2024
4
4
ms.topic: conceptual
5
5
description: "This article provides a conceptual overview of the Azure RBAC capability on Azure Arc-enabled Kubernetes."
6
6
---
7
7
8
-
# Azure RBAC on Azure Arc-enabled Kubernetes clusters (preview)
8
+
# Azure RBAC on Azure Arc-enabled Kubernetes clusters
9
9
10
10
Kubernetes [ClusterRoleBinding and RoleBinding](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#rolebinding-and-clusterrolebinding) object types help to define authorization in Kubernetes natively. With Azure role-based access control (Azure RBAC), you can use Microsoft Entra ID and role assignments in Azure to control authorization checks on the cluster. This allows the benefits of Azure role assignments, such as activity logs showing all Azure RBAC changes to an Azure resource, to be used with your Azure Arc-enabled Kubernetes cluster.
11
11
12
-
[!INCLUDE [preview features note](./includes/preview/preview-callout.md)]
0 commit comments