Updated ACR and AKS auth command (#540)

Co-authored-by: Sriramdas Balaji <sriramdas.balaji@outlook.com>
This commit is contained in:
sriramdasbalaji 2021-04-30 12:40:58 +05:30 коммит произвёл GitHub
Родитель ee8745ab87
Коммит 8f6759b647
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 2 добавлений и 9 удалений

Просмотреть файл

@ -88,17 +88,10 @@ The following azure resources need to be configured for this lab:
az acr create --resource-group akshandsonlab --name <unique-acr-name> --sku Standard --location <region>
```
{% include important.html content= "Enter a unique ACR name. ACR name may contain alpha numeric characters only and must be between 5 and 50 characters" %}
1. **Grant AKS-generated Managed Identity access to ACR** : Authorize the AKS cluster to connect to the Azure Container Registry using the AKS generated Managed Identity. Replace the variables `$AKS_RESOURCE_GROUP, $AKS_CLUSTER_NAME, $ACR_RESOURCE_GROUP` with appropriate values below and run the commands.
1. **Authenticate with Azure Container Registry from Azure Kubernetes Service** : When you're using Azure Container Registry (ACR) with Azure Kubernetes Service (AKS), an authentication mechanism needs to be established. You can set up the AKS to ACR integration in a few simple commands with the Azure CLI. This integration assigns the **AcrPull** role to the managed identity associated to the AKS Cluster. Replace the variables `$AKS_RESOURCE_GROUP, $AKS_CLUSTER_NAME, $ACR_NAME` with appropriate values below and run the command.
```bash
# Get the id of the Managed Identity configured for AKS
CLIENT_ID=$(az aks show --resource-group $AKS_RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query "identityProfile.kubeletidentity.clientId" --output tsv)
# Get the ACR registry resource id
ACR_ID=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query "id" --output tsv)
# Create role assignment
az role assignment create --assignee $CLIENT_ID --role acrpull --scope $ACR_ID
az aks update -n $AKS_CLUSTER_NAME -g $AKS_RESOURCE_GROUP --attach-acr $ACR_NAME
```
> For more information see document on how to [Authenticate with Azure Container Registry from Azure Kubernetes Service](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks){:target="_blank"}