Skip to content

Commit

Permalink
Updated ACR and AKS auth command (microsoft#540)
Browse files Browse the repository at this point in the history
Co-authored-by: Sriramdas Balaji <[email protected]>
  • Loading branch information
sriramdasbalaji and Sriramdas Balaji authored Apr 30, 2021
1 parent ee8745a commit 8f6759b
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions labs/vstsextend/kubernetes/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down

0 comments on commit 8f6759b

Please sign in to comment.