Skip to content

Commit 3de02bf

Browse files
committed
Learn Editor: Update cannot-pull-image-from-acr-to-aks-cluster.md
1 parent c87c096 commit 3de02bf

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

support/azure/azure-kubernetes/extensions/cannot-pull-image-from-acr-to-aks-cluster.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.custom: sap:Extensions, Policies and Add-Ons, devx-track-azurecli
1212

1313
[!INCLUDE [Feedback](../../../includes/feedback.md)]
1414

15-
When you're using Microsoft Azure Container Registry together with Azure Kubernetes Service (AKS), an authentication mechanism must be established. You can set up the AKS to Container Registry integration by using a few simple Azure CLI or Azure PowerShell commands. This integration assigns the [AcrPull role](/azure/role-based-access-control/built-in-roles#acrpull) for the kubelet identity that's associated with the AKS cluster to pull images from a container registry.
15+
When you're using Microsoft Azure Container Registry together with Azure Kubernetes Service (AKS), an authentication mechanism must be established. You can set up the AKS to Container Registry integration by using a few simple Azure CLI or Azure PowerShell commands. This integration assigns either the [Container Registry Repository Reader role](/azure/role-based-access-control/built-in-roles#container-registry-repository-reader) (for ABAC-enabled registries) or the [AcrPull role](/azure/role-based-access-control/built-in-roles#acrpull) (for non-ABAC-enabled registries) for the kubelet identity that's associated with the AKS cluster to pull images from a container registry. Please see https://aka.ms/acr/auth/abac for more information on the necessary ACR role to assign based on whether your ACR registry is ABAC-enabled.
1616

1717
In some cases, trying to pull images from a container registry to an AKS cluster fails. This article provides guidance for troubleshooting the most common errors that you encounter when you pull images from a container registry to an AKS cluster.
1818

@@ -24,7 +24,6 @@ This article assumes that you have an existing AKS cluster and an existing conta
2424

2525
- If you need an Azure Container Registry (ACR), create one by using [the Azure CLI](/azure/container-registry/container-registry-get-started-azure-cli) or [the Azure portal](/azure/container-registry/container-registry-get-started-portal).
2626

27-
2827
You also need Azure CLI version 2.0.59 or a later version to be installed and configured. Run [az version](/cli/azure/reference-index#az-version) to determine the version. If you have to install or upgrade, see [Install Azure CLI](/cli/azure/install-azure-cli).
2928

3029
## Symptoms and initial troubleshooting
@@ -72,11 +71,15 @@ Several solutions can help you resolve this error, subject to the following cons
7271

7372
- Solutions [5][cause1-solution5] and [6][cause1-solution6] are applicable for the Kubernetes method of [pulling a Kubernetes secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/).
7473

75-
#### Solution 1: Make sure AcrPull role assignment is created for identity
74+
#### Solution 1: Make sure the correct ACR role assignment is created for identity
75+
76+
The integration between AKS and Container Registry creates the correct role assignment at container registry level for the AKS cluster's kubelet identity.
7677

77-
The integration between AKS and Container Registry creates an AcrPull role assignment at container registry level for the AKS cluster's kubelet identity. Make sure that the role assignment is created.
78+
> [!NOTE]
79+
> Make sure that the correct role assignment is created (`Container Registry Repository Reader` for ABAC-enabled regisries, and `AcrPull` for non-ABAC-enabled registries).
80+
> Please see https://aka.ms/acr/auth/abac for more information on the correct ACR role needed based on whether the registry is ABAC-enabled or not.
7881
79-
To check whether the AcrPull role assignment is created, use one of the following methods:
82+
To check whether the correct ACR role assignment exists, use one of the following methods:
8083

8184
- Run the following command:
8285

@@ -86,14 +89,18 @@ To check whether the AcrPull role assignment is created, use one of the followin
8689

8790
- Check in the Azure portal by selecting **Azure Container Registry** > **Access control (IAM)** > **Role assignments**. For more information, see [List Azure role assignments using the Azure portal](/azure/role-based-access-control/role-assignments-list-portal).
8891

89-
Besides the AcrPull role, some [built-in roles](/azure/role-based-access-control/built-in-roles) and [custom roles](/azure/role-based-access-control/custom-roles) can also contain the "[Microsoft.ContainerRegistry](/azure/role-based-access-control/resource-provider-operations#microsoftcontainerregistry)/registries/pull/read" action. Check those roles if you've got any of them.
92+
Besides either the `Container Registry Repository Reader` role (for ABAC-enabled registries) and `AcrPull` role (for non-ABAC-enabled registries), some [built-in roles](/azure/role-based-access-control/built-in-roles) and [custom roles](/azure/role-based-access-control/custom-roles) can also contain the necessary Entra permissions for image pull. Check those roles if you've got any of them.
9093

91-
If the AcrPull role assignment isn't created, create it by [configuring Container Registry integration for the AKS cluster](/azure/aks/cluster-container-registry-integration?tabs=azure-cli#configure-acr-integration-for-existing-aks-clusters) with the following command:
94+
If either the `Container Registry Repository Reader` role (for ABAC-enabled registries) or `AcrPull` role (for non-ABAC-enabled registries) don't exist, you can create the role assignment.
95+
96+
For non-ABAC-enabled registries, you can assign the `AcrPull` role with the following command:
9297

9398
```azurecli
9499
az aks update -n <myAKSCluster> -g <myResourceGroup> --attach-acr <acr-resource-id>
95100
```
96101

102+
For ABAC-enabled registries, the `az aks --attach-acr` command does not support adding the `Container Registry Repository Reader` role. You must manually assign this role to the AKS kubelet identity with either the Azure Portal or the `az role assignment` CLI commands.
103+
97104
#### Solution 2: Make sure service principal isn't expired
98105

99106
Make sure that the secret of the service principal that's associated with the AKS cluster isn't expired. To check the expiration date of your service principal, run the following commands:
@@ -109,7 +116,7 @@ For more information, see [Check the expiration date of your service principal](
109116

110117
If the secret is expired, [update the credentials for the AKS cluster](/azure/aks/update-credentials).
111118

112-
#### Solution 3: Make sure AcrPull role is assigned to correct service principal
119+
#### Solution 3: Make sure the correct ACR role is assigned to correct service principal
113120

114121
In some cases, the container registry role assignment still refers to the old service principal. For example, when the service principal of the AKS cluster is replaced with a new one. To make sure that the container registry role assignment refers to the correct service principal, follow these steps:
115122

@@ -396,9 +403,9 @@ If the troubleshooting guidance in this article doesn't help you resolve the iss
396403
397404
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
398405
399-
[cause1-solution1]: #solution-1-make-sure-acrpull-role-assignment-is-created-for-identity
406+
[cause1-solution1]: #solution-1-make-sure-the-correct-acr-role-assignment-is-created-for-identity
400407
[cause1-solution2]: #solution-2-make-sure-service-principal-isnt-expired
401-
[cause1-solution3]: #solution-3-make-sure-acrpull-role-is-assigned-to-correct-service-principal
408+
[cause1-solution3]: #solution-3-make-sure-the-correct-acr-role-is-assigned-to-correct-service-principal
402409
[cause1-solution4]: #solution-4-make-sure-the-kubelet-identity-is-referenced-in-the-aks-vmss
403410
[cause1-solution5]: #solution-5-make-sure-the-service-principal-is-correct-and-the-secret-is-valid
404411
[cause1-solution6]: #solution-6-make-sure-the-kubernetes-secret-has-the-correct-values-of-the-container-registry-admin-account

0 commit comments

Comments
 (0)