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/use-network-policies.md
+6-24Lines changed: 6 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,48 +60,31 @@ First, let's create an AKS cluster that supports network policy.
60
60
>
61
61
> The network policy feature can only be enabled when the cluster is created. You can't enable network policy on an existing AKS cluster.
62
62
63
-
To use Azure Network Policy, you must use the [Azure CNI plug-in][azure-cni] and define your own virtual network and subnets. For more detailed information on how to plan out the required subnet ranges, see [configure advanced networking][use-advanced-networking]. Calico Network Policy could be used with either this same Azure CNI plug-in or with the Kubenet CNI plug-in.
63
+
To use Azure Network Policy, you must use the [Azure CNI plug-in][azure-cni]. Calico Network Policy could be used with either this same Azure CNI plug-in or with the Kubenet CNI plug-in.
64
64
65
65
The following example script:
66
66
67
-
* Creates a virtual network and subnet.
68
-
* Creates an AKS cluster in the defined virtual network with system-assigned identity and enables network policy.
67
+
* Creates an AKS cluster with system-assigned identity and enables network policy.
69
68
* 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`.
70
69
71
70
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).
72
71
72
+
### Create an AKS cluster for Azure network policies
73
+
73
74
You can replace the *RESOURCE_GROUP_NAME* and *CLUSTER_NAME* variables:
74
75
75
76
```azurecli-interactive
76
77
RESOURCE_GROUP_NAME=myResourceGroup-NP
77
78
CLUSTER_NAME=myAKSCluster
78
79
LOCATION=canadaeast
79
80
80
-
# Create a resource group
81
-
az group create --name $RESOURCE_GROUP_NAME --location $LOCATION
82
-
83
-
# Create a virtual network and subnet
84
-
az network vnet create \
85
-
--resource-group $RESOURCE_GROUP_NAME \
86
-
--name myVnet \
87
-
--address-prefixes 10.0.0.0/8 \
88
-
--subnet-name myAKSSubnet \
89
-
--subnet-prefix 10.240.0.0/16
90
-
91
-
# Get the virtual network subnet resource ID
92
-
SUBNET_ID=$(az network vnet subnet show --resource-group $RESOURCE_GROUP_NAME --vnet-name myVnet --name myAKSSubnet --query id -o tsv)
93
-
```
94
-
95
-
### Create an AKS cluster for Azure network policies
96
-
97
-
Create the AKS cluster and specify the virtual network and *azure* for the network plugin and network policy.
81
+
Create the AKS cluster and specify *azure* for the network plugin and network policy.
98
82
99
83
```azurecli
100
84
az aks create \
101
85
--resource-group $RESOURCE_GROUP_NAME \
102
86
--name $CLUSTER_NAME \
103
87
--node-count 1 \
104
-
--vnet-subnet-id $SUBNET_ID \
105
88
--network-plugin azure \
106
89
--network-policy azure
107
90
```
@@ -114,7 +97,7 @@ az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAM
114
97
115
98
### Create an AKS cluster for Calico network policies
116
99
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.
100
+
Create the AKS cluster and specify *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.
118
101
119
102
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`.
0 commit comments