Skip to content

Commit ff85000

Browse files
authored
Merge pull request #209716 from Khushbu-Parekh/npm-windows
Updated the docs with Windows NPM Public Preview details
2 parents b19c6e0 + 3a5b4a9 commit ff85000

File tree

2 files changed

+84
-16
lines changed

2 files changed

+84
-16
lines changed

articles/aks/use-network-policies.md

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This article shows you how to install the Network Policy engine and create Kuber
1616

1717
## Before you begin
1818

19-
You need the Azure CLI version 2.0.61 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
19+
You need the Azure CLI version 2.0.61 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
2020

2121
## Overview of Network Policy
2222

@@ -33,19 +33,31 @@ Azure provides two ways to implement Network Policy. You choose a Network Policy
3333
* Azure's own implementation, called *Azure Network Policy Manager (NPM)*.
3434
* *Calico Network Policies*, an open-source network and network security solution founded by [Tigera][tigera].
3535

36-
Azure NPM for Linux uses Linux *IPTables* to enforce the specified policies. Policies are translated into sets of allowed and disallowed IP pairs. These pairs are then programmed as IPTable filter rules.
36+
Azure NPM for Linux uses Linux *IPTables* and Azure NPM for Windows uses *Host Network Service (HNS) ACLPolicies* to enforce the specified policies. Policies are translated into sets of allowed and disallowed IP pairs. These pairs are then programmed as IPTable/HNS ACLPolicy filter rules.
3737

3838
## Differences between Azure NPM and Calico Network Policy and their capabilities
3939

4040
| Capability | Azure NPM | Calico Network Policy |
4141
|------------------------------------------|----------------------------|-----------------------------|
42-
| Supported platforms | Linux | Linux, Windows Server 2019 and 2022 |
42+
| Supported platforms | Linux, Windows Server 2022 | Linux, Windows Server 2019 and 2022 |
4343
| Supported networking options | Azure CNI | Azure CNI (Linux, Windows Server 2019 and 2022) and kubenet (Linux) |
4444
| Compliance with Kubernetes specification | All policy types supported | All policy types supported |
4545
| Additional features | None | Extended policy model consisting of Global Network Policy, Global Network Set, and Host Endpoint. For more information on using the `calicoctl` CLI to manage these extended features, see [calicoctl user reference][calicoctl]. |
4646
| Support | Supported by Azure support and Engineering team | Calico community support. For more information on additional paid support, see [Project Calico support options][calico-support]. |
4747
| Logging | Logs available with **kubectl log -n kube-system <network-policy-pod>** command | For more information, see [Calico component logs][calico-logs] |
4848

49+
## Limitations:
50+
51+
Azure Network Policy Manager(NPM) doesn't support IPv6. Otherwise, Azure NPM fully supports the network policy spec in Linux.
52+
* In Windows, Azure NPM doesn't support the following:
53+
* named ports
54+
* SCTP protocol
55+
* negative match label or namespace selectors (e.g. all labels except "debug=true")
56+
* "except" CIDR blocks (a CIDR with exceptions)
57+
58+
>[!NOTE]
59+
> * Azure NPM pod logs will record an error if an unsupported policy is created.
60+
4961
## Create an AKS cluster and enable Network Policy
5062

5163
To see network policies in action, let's create an AKS cluster that supports network policy and then work on adding policies.
@@ -63,9 +75,9 @@ The following example script:
6375

6476
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).
6577

66-
### Create an AKS cluster with Azure NPM enabled
78+
### Create an AKS cluster with Azure NPM enabled - Linux only
6779

68-
In this section, we will work on creating a cluster with Linux node pools and Azure NPM enabled.
80+
In this section, we'll work on creating a cluster with Linux node pools and Azure NPM enabled.
6981

7082
To begin, you should replace the values for *$RESOURCE_GROUP_NAME* and *$CLUSTER_NAME* variables.
7183

@@ -87,6 +99,64 @@ az aks create \
8799
--network-policy azure
88100
```
89101

102+
### Create an AKS cluster with Azure NPM enabled - Windows Server 2022 (Preview)
103+
104+
In this section, we'll work on creating a cluster with Windows node pools and Azure NPM enabled.
105+
106+
Please execute the following commands prior to creating a cluster:
107+
108+
```azurecli
109+
az extension add --name aks-preview
110+
az extension update --name aks-preview
111+
az feature register --namespace Microsoft.ContainerService --name AKSWindows2022Preview
112+
az feature register --namespace Microsoft.ContainerService --name WindowsNetworkPolicyPreview
113+
az provider register -n Microsoft.ContainerService
114+
```
115+
116+
> [!NOTE]
117+
> At this time, Azure NPM with Windows nodes is available on Windows Server 2022 only
118+
>
119+
120+
Now, you should replace the values for *$RESOURCE_GROUP_NAME*, *$CLUSTER_NAME* and *$WINDOWS_USERNAME* variables.
121+
122+
```azurecli-interactive
123+
$RESOURCE_GROUP_NAME=myResourceGroup-NP
124+
$CLUSTER_NAME=myAKSCluster
125+
$WINDOWS_USERNAME=myWindowsUserName
126+
$LOCATION=canadaeast
127+
```
128+
129+
Create a username to use as administrator credentials for your Windows Server containers on your cluster. The following command prompts you for a username. Set it to `$WINDOWS_USERNAME`(remember that the commands in this article are entered into a BASH shell).
130+
131+
```azurecli-interactive
132+
echo "Please enter the username to use as administrator credentials for Windows Server containers on your cluster: " && read WINDOWS_USERNAME
133+
```
134+
135+
Use the following command to create a cluster:
136+
137+
```azurecli
138+
az aks create \
139+
--resource-group $RESOURCE_GROUP_NAME \
140+
--name $CLUSTER_NAME \
141+
--node-count 1 \
142+
--windows-admin-username $WINDOWS_USERNAME \
143+
--network-plugin azure \
144+
--network-policy azure
145+
```
146+
147+
It takes a few minutes to create the cluster. By default, your cluster is created with only a Linux node pool. If you would like to use Windows node pools, you can add one. For example:
148+
149+
```azurecli
150+
az aks nodepool add \
151+
--resource-group $RESOURCE_GROUP_NAME \
152+
--cluster-name $CLUSTER_NAME \
153+
--os-type Windows \
154+
--name npwin \
155+
--node-count 1
156+
```
157+
158+
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
159+
90160
### Create an AKS cluster for Calico network policies
91161

92162
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.
@@ -132,15 +202,15 @@ When the cluster is ready, configure `kubectl` to connect to your Kubernetes clu
132202
```azurecli-interactive
133203
az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAME
134204
```
135-
To begin verification of Network Policy, we will create a sample application and set traffic rules.
205+
To begin verification of Network Policy, we'll create a sample application and set traffic rules.
136206

137207
Firstly, let's create a namespace called *demo* to run the example pods:
138208

139209
```console
140210
kubectl create namespace demo
141211
```
142212

143-
We will now create two pods in the cluster named *client* and *server*.
213+
We'll now create two pods in the cluster named *client* and *server*.
144214

145215
>[!NOTE]
146216
> If you want to schedule the *client* or *server* on a particular node, add the following bit before the *--command* argument in the pod creation [kubectl run][kubectl-run] command:
@@ -214,7 +284,7 @@ Now, in the client's shell, verify connectivity with the server by executing the
214284
/agnhost connect <server-ip>:80 --timeout=3s --protocol=tcp
215285
```
216286

217-
Connectivity with traffic will be blocked since the server is labeled with app=server, but the client is not labeled. The connect command above will yield this output:
287+
Connectivity with traffic will be blocked since the server is labeled with app=server, but the client isn't labeled. The connect command above will yield this output:
218288

219289
```output
220290
TIMEOUT
@@ -265,4 +335,4 @@ To learn more about policies, see [Kubernetes network policies][kubernetes-netwo
265335
[windows-server-password]: /windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements#reference
266336
[az-extension-add]: /cli/azure/extension#az_extension_add
267337
[az-extension-update]: /cli/azure/extension#az_extension_update
268-
[dsr]: ../load-balancer/load-balancer-multivip-overview.md#rule-type-2-backend-port-reuse-by-using-floating-ip
338+
[dsr]: ../load-balancer/load-balancer-multivip-overview.md#rule-type-2-backend-port-reuse-by-using-floating-ip

articles/virtual-network/kubernetes-network-policies.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Network Policies provides micro-segmentation for pods just like Network Security
2626

2727
![Kubernetes network policies overview](./media/kubernetes-network-policies/kubernetes-network-policies-overview.png)
2828

29-
Azure NPM implementation works in conjunction with the Azure CNI that provides VNet integration for containers. NPM is supported only on Linux today. The implementation enforces traffic filtering by configuring allow and deny IP rules in Linux IPTables based on the defined policies. These rules are grouped together using Linux IPSets.
29+
Azure NPM implementation works with the Azure CNI that provides VNet integration for containers. NPM is supported only on Linux today. The implementation enforces traffic filtering by configuring allow and deny IP rules in Linux IPTables based on the defined policies. These rules are grouped together using Linux IPSets.
3030

3131
## Planning security for your Kubernetes cluster
3232
When implementing security for your cluster, use network security groups (NSGs) to filter traffic entering and leaving your cluster subnet (North-South traffic). Use Azure NPM for traffic between pods in your cluster (East-West traffic).
@@ -75,8 +75,8 @@ See a [configuration for these alerts](#set-up-alerts-for-alertmanager) below.
7575

7676
##### Visualizations and Debugging via our Grafana Dashboard or Azure Monitor Workbook
7777
1. See how many IPTables rules your policies create (having a massive amount of IPTables rules may increase latency slightly).
78-
2. Correlate cluster counts (e.g. ACLs) to execution times.
79-
3. Get the human-friendly name of an ipset in a given IPTables rule (e.g. "azure-npm-487392" represents "podlabel-role:database").
78+
2. Correlate cluster counts (for example, ACLs) to execution times.
79+
3. Get the human-friendly name of an ipset in a given IPTables rule (for example, "azure-npm-487392" represents "podlabel-role:database").
8080

8181
### All supported metrics
8282
The following is the list of supported metrics. Any `quantile` label has possible values `0.5`, `0.9`, and `0.99`. Any `had_error` label has possible values `false` and `true`, representing whether the operation succeeded or failed.
@@ -137,7 +137,7 @@ The dashboard has visuals similar to the Azure Workbook. You can add panels to c
137137
### Set up for Prometheus Server
138138
Some users may choose to collect metrics with a Prometheus Server instead of Azure Monitor for containers. You merely need to add two jobs to your scrape config to collect NPM metrics.
139139

140-
To install a simple Prometheus Server, add this helm repo on your cluster
140+
To install a Prometheus Server, add this helm repo on your cluster
141141
```
142142
helm repo add stable https://kubernetes-charts.storage.googleapis.com
143143
helm repo update
@@ -178,7 +178,6 @@ where `prometheus-server-scrape-config.yaml` consists of
178178
action: drop
179179
```
180180

181-
182181
You can also replace the `azure-npm-node-metrics` job with the content below or incorporate it into a pre-existing job for Kubernetes pods:
183182
```
184183
- job_name: "azure-npm-node-metrics-from-pod-config"
@@ -199,7 +198,7 @@ You can also replace the `azure-npm-node-metrics` job with the content below or
199198
```
200199

201200
#### Set up Alerts for AlertManager
202-
If you use a Prometheus Server, you can set up an AlertManager like so. Here is an example config for [the two alerting rules described above](#alerts-via-a-prometheus-alertmanager):
201+
If you use a Prometheus Server, you can set up an AlertManager like so. Here's an example config for [the two alerting rules described above](#alerts-via-a-prometheus-alertmanager):
203202
```
204203
groups:
205204
- name: npm.rules
@@ -263,7 +262,6 @@ Following are some sample dashboard for NPM metrics in Container Insights (CI) a
263262
[![Grafana Dashboard runtime quantiles](media/kubernetes-network-policies/grafana-runtime-quantiles.png)](media/kubernetes-network-policies/grafana-runtime-quantiles.png#lightbox)
264263

265264

266-
267265
## Next steps
268266
- Learn about [Azure Kubernetes Service](../aks/intro-kubernetes.md).
269267
- Learn about [container networking](container-networking-overview.md).

0 commit comments

Comments
 (0)