Skip to content

Commit 35d1887

Browse files
authored
Merge pull request #202882 from CocoWang-wql/patch-4
update virtual-nodes-cli.md
2 parents fec47f7 + 1a9e465 commit 35d1887

File tree

1 file changed

+6
-49
lines changed

1 file changed

+6
-49
lines changed

articles/aks/virtual-nodes-cli.md

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ titleSuffix: Azure Kubernetes Service
44
description: Learn how to use the Azure CLI to create an Azure Kubernetes Services (AKS) cluster that uses virtual nodes to run pods.
55
services: container-service
66
ms.topic: conceptual
7-
ms.date: 03/16/2021
7+
ms.date: 06/25/2022
88
ms.custom: references_regions, devx-track-azurecli
99
---
1010

@@ -79,68 +79,25 @@ az network vnet subnet create \
7979
--address-prefixes 10.241.0.0/16
8080
```
8181

82-
## Create a service principal or use a managed identity
82+
## Create an AKS cluster with managed identity
8383

84-
To allow an AKS cluster to interact with other Azure resources, a cluster identity is used. This cluster identity can be automatically created by the Azure CLI or portal, or you can pre-create one and assign additional permissions. By default, this cluster identity is a managed identity. For more information, see [Use managed identities](use-managed-identity.md). You can also use a service principal as your cluster identity. The following steps show you how to manually create and assign the service principal to your cluster.
85-
86-
Create a service principal using the [az ad sp create-for-rbac][az-ad-sp-create-for-rbac] command.
87-
88-
```azurecli-interactive
89-
az ad sp create-for-rbac
90-
```
91-
92-
The output is similar to the following example:
93-
94-
```output
95-
{
96-
"appId": "bef76eb3-d743-4a97-9534-03e9388811fc",
97-
"displayName": "azure-cli-2018-11-21-18-42-00",
98-
"name": "http://azure-cli-2018-11-21-18-42-00",
99-
"password": "1d257915-8714-4ce7-a7fb-0e5a5411df7f",
100-
"tenant": "72f988bf-86f1-41af-91ab-2d7cd011db48"
101-
}
102-
```
103-
104-
Make a note of the *appId* and *password*. These values are used in the following steps.
105-
106-
## Assign permissions to the virtual network
107-
108-
To allow your cluster to use and manage the virtual network, you must grant the AKS service principal the correct rights to use the network resources.
109-
110-
First, get the virtual network resource ID using [az network vnet show][az-network-vnet-show]:
111-
112-
```azurecli-interactive
113-
az network vnet show --resource-group myResourceGroup --name myVnet --query id -o tsv
114-
```
115-
116-
To grant the correct access for the AKS cluster to use the virtual network, create a role assignment using the [az role assignment create][az-role-assignment-create] command. Replace `<appId`> and `<vnetId>` with the values gathered in the previous two steps.
117-
118-
```azurecli-interactive
119-
az role assignment create --assignee <appId> --scope <vnetId> --role Contributor
120-
```
121-
122-
## Create an AKS cluster
84+
Instead of using a system-assigned identity, you can also use a user-assigned identity. For more information, see [Use managed identities](use-managed-identity.md).
12385

12486
You deploy an AKS cluster into the AKS subnet created in a previous step. Get the ID of this subnet using [az network vnet subnet show][az-network-vnet-subnet-show]:
12587

12688
```azurecli-interactive
12789
az network vnet subnet show --resource-group myResourceGroup --vnet-name myVnet --name myAKSSubnet --query id -o tsv
12890
```
12991

130-
Use the [az aks create][az-aks-create] command to create an AKS cluster. The following example creates a cluster named *myAKSCluster* with one node. Replace `<subnetId>` with the ID obtained in the previous step, and then `<appId>` and `<password>` with the values gathered in the previous section.
92+
Use the [az aks create][az-aks-create] command to create an AKS cluster. The following example creates a cluster named *myAKSCluster* with one node. Replace `<subnetId>` with the ID obtained in the previous step.
13193

13294
```azurecli-interactive
13395
az aks create \
13496
--resource-group myResourceGroup \
13597
--name myAKSCluster \
13698
--node-count 1 \
13799
--network-plugin azure \
138-
--service-cidr 10.0.0.0/16 \
139-
--dns-service-ip 10.0.0.10 \
140-
--docker-bridge-address 172.17.0.1/16 \
141100
--vnet-subnet-id <subnetId> \
142-
--service-principal <appId> \
143-
--client-secret <password>
144101
```
145102

146103
After several minutes, the command completes and returns JSON-formatted information about the cluster.
@@ -308,7 +265,7 @@ az network profile delete --id $NETWORK_PROFILE_ID -y
308265
SAL_ID=$(az network vnet subnet show --resource-group $RES_GROUP --vnet-name $AKS_VNET --name $AKS_SUBNET --query id --output tsv)/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default
309266
310267
# Delete the service association link for the subnet
311-
az resource delete --ids $SAL_ID --api-version {api-version}
268+
az resource delete --ids $SAL_ID --api-version 2021-10-01
312269
313270
# Delete the subnet delegation to Azure Container Instances
314271
az network vnet subnet update --resource-group $RES_GROUP --vnet-name $AKS_VNET --name $AKS_SUBNET --remove delegations
@@ -355,4 +312,4 @@ Virtual nodes are often one component of a scaling solution in AKS. For more inf
355312
[az-provider-list]: /cli/azure/provider#az_provider_list
356313
[az-provider-register]: /cli/azure/provider#az_provider_register
357314
[virtual-nodes-aks]: virtual-nodes.md
358-
[virtual-nodes-networking-aci]: ../container-instances/container-instances-virtual-network-concepts.md
315+
[virtual-nodes-networking-aci]: ../container-instances/container-instances-virtual-network-concepts.md

0 commit comments

Comments
 (0)