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
+56-29Lines changed: 56 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,9 @@ You can set up the AKS to ACR integration in a few steps using the Azure CLI, Az
26
26
27
27
## Create a new AKS cluster with ACR integration
28
28
29
-
You can set up AKS and ACR integration during the creation of your AKS cluster. To allow an AKS cluster to interact with ACR, an AAD **managed identity** is used. The following command allows you to authorize an existing ACR in your subscription and configures the appropriate **AcrPull** role for the managed identity. Supply valid values for your parameters below.
29
+
You can set up AKS and ACR integration during the creation of your AKS cluster. To allow an AKS cluster to interact with ACR, an AAD **managed identity** is used.
30
+
31
+
If you don't already have an ACR, create one using the following command.
30
32
31
33
### [Azure CLI](#tab/azure-cli)
32
34
@@ -35,21 +37,41 @@ You can set up AKS and ACR integration during the creation of your AKS cluster.
35
37
36
38
MYACR=myContainerRegistry
37
39
38
-
# If you don't already have an ACR, use the following command to create one.
39
-
40
40
az acr create -n $MYACR -g myContainerRegistryResourceGroup --sku basic
41
+
```
42
+
43
+
### [Azure PowerShell][#tab/azure-powershell]
44
+
45
+
```azurepowershell
46
+
# Set this variable to the name of your ACR. The name must be globally unique.
If you have already have an ACR, use the following command to create a new AKS cluster with ACR integration. This command allows you to authorize an existing ACR in your subscription and configures the appropriate **AcrPull** role for the managed identity. Supply valid values for your parameters below.
56
+
57
+
### [Azure CLI](#tab/azure-cli)
58
+
59
+
```azurecli
60
+
# Set this variable to the name of your ACR. The name must be globally unique.
61
+
62
+
MYACR=myContainerRegistry
41
63
42
64
# Create an AKS cluster with ACR integration.
43
65
44
66
az aks create -n myAKSCluster -g myResourceGroup --generate-ssh-keys --attach-acr $MYACR
45
67
```
46
68
47
-
Alternatively, you can specify the ACR name using an ACR resource ID. The format is as follows:
69
+
Alternatively, you can specify the ACR name using an ACR resource ID using the following format:
> If you're using an ACR located in a different subscription from your AKS cluster, use the ACR resource ID when attaching or detaching from the cluster.
74
+
> If you're using an ACR located in a different subscription from your AKS cluster, use the ACR *resource ID* when attaching or detaching from the cluster.
53
75
>
54
76
> ```azurecli
55
77
> az aks create -n myAKSCluster -g myResourceGroup --generate-ssh-keys --attach-acr /subscriptions/<subscription-id>/resourceGroups/myContainerRegistryResourceGroup/providers/Microsoft.ContainerRegistry/registries/myContainerRegistry
@@ -62,10 +84,6 @@ Alternatively, you can specify the ACR name using an ACR resource ID. The format
62
84
63
85
$MYACR = 'myContainerRegistry'
64
86
65
-
# If you don't already have an ACR, use the following command to create one.
@@ -77,47 +95,53 @@ This step may take several minutes to complete.
77
95
78
96
## Configure ACR integration for existing AKS clusters
79
97
98
+
### Attach an ACR to an AKS cluster
99
+
80
100
### [Azure CLI](#tab/azure-cli)
81
101
82
-
Integrate an existing ACR with existing AKS clusters by supplying valid values for **acr-name** or **acr-resource-id**.
102
+
Integrate an existing ACR with an existing AKS cluster using the [`--attach-acr` parameter][cli-param] and valid values for **acr-name** or **acr-resource-id**.
83
103
84
104
```azurecli
105
+
# Attach using acr-name
85
106
az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acr-name>
86
-
```
87
-
88
-
or
89
107
90
-
```azurecli
108
+
# Attach using acr-resource-id
91
109
az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acr-resource-id>
92
110
```
93
111
94
112
> [!NOTE]
95
113
> The `az aks update --attach-acr` command uses the permissions of the user running the command to create the ACR role assignment. This role is assigned to the [kubelet][kubelet] managed identity. For more information on AKS managed identities, see [Summary of managed identities][summary-msi].
96
114
97
-
You can also remove the integration between an ACR and an AKS cluster.
98
-
99
-
```azurecli
100
-
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-name>
101
-
```
102
-
103
-
or
104
-
105
-
```azurecli
106
-
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-resource-id>
107
-
```
108
-
109
115
### [Azure PowerShell](#tab/azure-powershell)
110
116
111
-
Integrate an existing ACR with existing AKS clusters by supplying valid values for **acr-name**.
117
+
Integrate an existing ACR with an existing AKS cluster using the [`-AcrNameToAttach` parameter][ps-attach] and valid values for **acr-name**.
> Running the `Set-AzAksCluster -AcrNameToAttach` cmdlet uses the permissions of the user running the command to create the role ACR assignment. This role is assigned to the [kubelet][kubelet] managed identity. For more information on AKS managed identities, see [Summary of managed identities][summary-msi].
119
127
120
-
You can also remove the integration between an ACR and an AKS cluster.
128
+
### Detach an ACR from an AKS cluster
129
+
130
+
### [Azure CLI][#tab/azure-cli]
131
+
132
+
Remove the integration between an ACR and an AKS cluster using the [`--detach-acr` parameter][cli-param] and valid values for **acr-name** or **acr-resource-id**.
133
+
134
+
```azurecli
135
+
# Detach using acr-name
136
+
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-name>
137
+
138
+
# Detach using acr-resource-id
139
+
az aks update -n myAKSCluster -g myResourceGroup --detach-acr <acr-resource-id>
140
+
```
141
+
142
+
### [Azure PowerShell][#tab/azure-powershell]
143
+
144
+
Remove the integration between an ACR and an AKS cluster using the [`-AcrNameToDetach` parameter][ps-detach] and valid values for **acr-name**.
Create a file called **acr-nginx.yaml** using the sample YAML below. Substitute the resource name of your registry for **acr-name**, such as *myContainerRegistry*.
190
+
Create a file called **acr-nginx.yaml** using the sample YAML below. Replace **acr-name** with the name of your ACR.
0 commit comments