Skip to content

Commit 82a5492

Browse files
authored
Update use-network-policies.md
1 parent 99a758e commit 82a5492

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

articles/aks/use-network-policies.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ titleSuffix: Azure Kubernetes Service
44
description: Learn how to secure traffic that flows in and out of pods by using Kubernetes network policies in Azure Kubernetes Service (AKS)
55
services: container-service
66
ms.topic: article
7-
ms.date: 03/29/2022
7+
ms.date: 06/24/2022
88

99
---
1010

@@ -65,14 +65,12 @@ To use Azure Network Policy, you must use the [Azure CNI plug-in][azure-cni] and
6565
The following example script:
6666

6767
* Creates a virtual network and subnet.
68-
* Creates an Azure Active Directory (Azure AD) service principal for use with the AKS cluster.
69-
* Assigns *Contributor* permissions for the AKS cluster service principal on the virtual network.
70-
* Creates an AKS cluster in the defined virtual network and enables network policy.
68+
* Creates an AKS cluster in the defined virtual network with system-assigned identity and enables network policy.
7169
* The _Azure Network_ policy option is used. To use Calico as the network policy option instead, use the `--network-policy calico` parameter. Note: Calico could be used with either `--network-plugin azure` or `--network-plugin kubenet`.
7270

73-
Note that instead of using a service principal, you can use a managed identity for permissions. For more information, see [Use managed identities](use-managed-identity.md).
71+
Note that 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).
7472

75-
Provide your own secure *SP_PASSWORD*. You can replace the *RESOURCE_GROUP_NAME* and *CLUSTER_NAME* variables:
73+
You can replace the *RESOURCE_GROUP_NAME* and *CLUSTER_NAME* variables:
7674

7775
```azurecli-interactive
7876
RESOURCE_GROUP_NAME=myResourceGroup-NP
@@ -90,41 +88,20 @@ az network vnet create \
9088
--subnet-name myAKSSubnet \
9189
--subnet-prefix 10.240.0.0/16
9290
93-
# Create a service principal and read in the application ID
94-
SP=$(az ad sp create-for-rbac --output json)
95-
SP_ID=$(echo $SP | jq -r .appId)
96-
SP_PASSWORD=$(echo $SP | jq -r .password)
97-
98-
# Wait 15 seconds to make sure that service principal has propagated
99-
echo "Waiting for service principal to propagate..."
100-
sleep 15
101-
102-
# Get the virtual network resource ID
103-
VNET_ID=$(az network vnet show --resource-group $RESOURCE_GROUP_NAME --name myVnet --query id -o tsv)
104-
105-
# Assign the service principal Contributor permissions to the virtual network resource
106-
az role assignment create --assignee $SP_ID --scope $VNET_ID --role Contributor
107-
10891
# Get the virtual network subnet resource ID
10992
SUBNET_ID=$(az network vnet subnet show --resource-group $RESOURCE_GROUP_NAME --vnet-name myVnet --name myAKSSubnet --query id -o tsv)
11093
```
11194

11295
### Create an AKS cluster for Azure network policies
11396

114-
Create the AKS cluster and specify the virtual network, service principal information, and *azure* for the network plugin and network policy.
97+
Create the AKS cluster and specify the virtual network and *azure* for the network plugin and network policy.
11598

11699
```azurecli
117100
az aks create \
118101
--resource-group $RESOURCE_GROUP_NAME \
119102
--name $CLUSTER_NAME \
120103
--node-count 1 \
121-
--generate-ssh-keys \
122-
--service-cidr 10.0.0.0/16 \
123-
--dns-service-ip 10.0.0.10 \
124-
--docker-bridge-address 172.17.0.1/16 \
125104
--vnet-subnet-id $SUBNET_ID \
126-
--service-principal $SP_ID \
127-
--client-secret $SP_PASSWORD \
128105
--network-plugin azure \
129106
--network-policy azure
130107
```
@@ -137,7 +114,7 @@ az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAM
137114

138115
### Create an AKS cluster for Calico network policies
139116

140-
Create the AKS cluster and specify the virtual network, service principal information, *azure* for the network plugin, and *calico* for the network policy. Using *calico* as the network policy enables Calico networking on both Linux and Windows node pools.
117+
Create the AKS cluster and specify the virtual network, *azure* for the network plugin, and *calico* for the network policy. Using *calico* as the network policy enables Calico networking on both Linux and Windows node pools.
141118

142119
If you plan on adding Windows node pools to your cluster, include the `windows-admin-username` and `windows-admin-password` parameters with that meet the [Windows Server password requirements][windows-server-password]. To use Calico with Windows node pools, you also need to register the `Microsoft.ContainerService/EnableAKSWindowsCalico`.
143120

@@ -179,16 +156,8 @@ az aks create \
179156
--resource-group $RESOURCE_GROUP_NAME \
180157
--name $CLUSTER_NAME \
181158
--node-count 1 \
182-
--generate-ssh-keys \
183-
--service-cidr 10.0.0.0/16 \
184-
--dns-service-ip 10.0.0.10 \
185-
--docker-bridge-address 172.17.0.1/16 \
186159
--vnet-subnet-id $SUBNET_ID \
187-
--service-principal $SP_ID \
188-
--client-secret $SP_PASSWORD \
189160
--windows-admin-username $WINDOWS_USERNAME \
190-
--vm-set-type VirtualMachineScaleSets \
191-
--kubernetes-version 1.20.2 \
192161
--network-plugin azure \
193162
--network-policy calico
194163
```

0 commit comments

Comments
 (0)