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/aks/cluster-container-registry-integration.md
+42-40Lines changed: 42 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,30 +13,39 @@ ms.author: mlearned
13
13
14
14
# Authenticate with Azure Container Registry from Azure Kubernetes Service
15
15
16
-
When you're using Azure Container Registry (ACR) with Azure Kubernetes Service (AKS), an authentication mechanism needs to be established. This article details the recommended configurations for authentication between these two Azure services.
16
+
When you're using Azure Container Registry (ACR) with Azure Kubernetes Service (AKS), an authentication mechanism needs to be established. This article provides examples for configuring authentication between these two Azure services.
17
17
18
18
You can set up the AKS to ACR integration in a few simple commands with the Azure CLI.
19
19
20
20
## Before you begin
21
21
22
-
You must have the following:
22
+
These examples require:
23
23
24
24
***Owner** or **Azure account administrator** role on the **Azure subscription**
25
-
* You also need the Azure CLI version 2.0.73 or later
26
-
* You need [Docker installed](https://docs.docker.com/install/) on your client, and you need access to [docker hub](https://hub.docker.com/)
25
+
* Azure CLI version 2.0.73 or later
27
26
28
27
## Create a new AKS cluster with ACR integration
29
28
30
29
You can set up AKS and ACR integration during the initial creation of your AKS cluster. To allow an AKS cluster to interact with ACR, an Azure Active Directory **service principal** is used. The following CLI command allows you to authorize an existing ACR in your subscription and configures the appropriate **ACRPull** role for the service principal. Supply valid values for your parameters below. The parameters in brackets are optional.
31
30
```azurecli
32
-
az login
33
-
az acr create -n myContainerRegistry -g myContainerRegistryResourceGroup --sku basic [in case you do not have an existing ACR]
34
-
az aks create -n myAKSCluster -g myResourceGroup --attach-acr <acr-name-or-resource-id>
31
+
# set this to the name of your Azure Container Registry. It must be globally unique
32
+
MYACR=myContainerRegistry
33
+
34
+
# Run the following line to create an Azure Container Registry if you do not already have one
35
+
az acr create -n $MYACR -g myContainerRegistryResourceGroup --sku basic
36
+
37
+
# Create an AKS cluster with ACR integration
38
+
az aks create -n myAKSCluster -g myResourceGroup --attach-acr $MYACR
39
+
35
40
```
36
-
**An ACR resource IDhas the following format:**
41
+
Alternatively, you can specify the ACR name using an ACR resource ID, which has has the following format:
az aks create -n myAKSCluster -g myResourceGroup --attach-acr /subscriptions/<subscription-id>/resourceGroups/myContainerRegistryResourceGroup/providers/Microsoft.ContainerRegistry/registries/myContainerRegistry
47
+
```
48
+
40
49
This step may take several minutes to complete.
41
50
42
51
## Configure ACR integration for existing AKS clusters
@@ -45,57 +54,43 @@ Integrate an existing ACR with existing AKS clusters by supplying valid values f
45
54
46
55
```azurecli
47
56
az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acrName>
57
+
```
58
+
or,
59
+
```
48
60
az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acr-resource-id>
49
61
```
50
62
51
63
You can also remove the integration between an ACR and an AKS cluster with the following
52
64
```azurecli
53
65
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acrName>
54
-
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-resource-id>
55
66
```
56
-
57
-
58
-
## Log in to your ACR
59
-
60
-
Use the following command to Log in to your ACR. Replace the <acrname> parameter with your ACR name. For example, the default is **aks<your-resource-group>acr**.
61
-
62
-
```azurecli
63
-
az acr login -n <acrName>
67
+
or
68
+
```
69
+
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-resource-id>
64
70
```
65
71
66
-
## Pull an image from docker hub and push to your ACR
72
+
## Working with ACR & AKS
67
73
68
-
Pull an image from docker hub, tag the image, and push to your ACR.
0 commit comments