Skip to content

Commit 82f3ee3

Browse files
Updated NPM user doc- Addressed PR comments by Nick and Hunter
1 parent 33a881e commit 82f3ee3

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

articles/aks/use-network-policies.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ All pods in an AKS cluster can send and receive traffic without limitations, by
2424

2525
Network Policy is a Kubernetes specification that defines access policies for communication between Pods. Using network policies, you define an ordered set of rules to send and receive traffic and apply them to a collection of pods that match one or more label selectors.
2626

27-
These Network Policy rules are defined as YAML manifests. Network Policies can be included as part of a wider manifest that also creates a deployment or service.
27+
These Network Policy rules are defined as YAML manifests. Network policies can be included as part of a wider manifest that also creates a deployment or service.
2828

2929
## Network policy options in AKS
3030

3131
Azure provides two ways to implement Network Policy. You choose a Network Policy option when you create an AKS cluster. The policy option can't be changed after the cluster is created:
3232

33-
* Azure's own implementation, called *Azure Network Policy Manager(NPM)*.
33+
* 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* 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.
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

@@ -48,7 +48,7 @@ Azure NPM for Linux uses Linux *IPTables* and Azure NPM for Windows uses *Host N
4848

4949
## Limitations:
5050

51-
*Azure Network Policy Manager(NPM) does not support IPv6. Otherwise, Azure NPM fully supports the network policy spec in Linux.
51+
Azure Network Policy Manager(NPM) does not support IPv6. Otherwise, Azure NPM fully supports the network policy spec in Linux.
5252
* In Windows, Azure NPM does not support the following:
5353
* named ports
5454
* SCTP protocol
@@ -111,6 +111,7 @@ Please execute the following commands prior to creating a cluster:
111111
az feature register --namespace Microsoft.ContainerService --name AKSWindows2022Preview
112112
az feature register --namespace Microsoft.ContainerService --name WindowsNetworkPolicyPreview
113113
az provider register -n Microsoft.ContainerService
114+
```
114115

115116
> [!NOTE]
116117
> At this time, Azure NPM with Windows nodes is available on Windows Server 2022 only
@@ -126,7 +127,14 @@ $WINDOWS_PASSWORD=myWindowsPassword
126127
$k8S_VERSION=myk8sVersion
127128
$LOCATION=canadaeast
128129
```
129-
Use the following command for cluster running with **Windows Server 2022** node pools:
130+
131+
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).
132+
133+
```azurecli-interactive
134+
echo "Please enter the username to use as administrator credentials for Windows Server containers on your cluster: " && read $WINDOWS_USERNAME
135+
```
136+
137+
Use the following command for a cluster running with **Windows Server 2022** node pools:
130138

131139
```azurecli
132140
az aks create \
@@ -141,9 +149,16 @@ az aks create \
141149
--node-count 1
142150
```
143151

144-
> [!NOTE]
145-
> You can still add Linux node pools to the cluster created using the above command, by default.
146-
>
152+
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:
153+
154+
```azurecli
155+
az aks nodepool add \
156+
--resource-group $RESOURCE_GROUP_NAME \
157+
--name $CLUSTER_NAME \
158+
--os-type Windows \
159+
--name npwin \
160+
--node-count 1
161+
```
147162

148163
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
149164

@@ -185,19 +200,14 @@ az aks nodepool add \
185200
--node-count 1
186201
```
187202

188-
When the cluster is ready, configure `kubectl` to connect to your Kubernetes cluster by using the [az aks get-credentials][az-aks-get-credentials] command. This command downloads credentials and configures the Kubernetes CLI to use them:
189-
190-
```azurecli-interactive
191-
az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAME
192-
```
193203
## Verify Network Policy Setup
194204

195-
It takes a few minutes to create the cluster. When the cluster is ready, configure `kubectl` to connect to your Kubernetes cluster by using the [az aks get-credentials][az-aks-get-credentials] command. This command downloads credentials and configures the Kubernetes CLI to use them:
205+
When the cluster is ready, configure `kubectl` to connect to your Kubernetes cluster by using the [az aks get-credentials][az-aks-get-credentials] command. This command downloads credentials and configures the Kubernetes CLI to use them:
196206

197207
```azurecli-interactive
198208
az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAME
199209
```
200-
To begin verification of network policy, we will create a sample application and set traffic rules.
210+
To begin verification of Network Policy, we will create a sample application and set traffic rules.
201211

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

@@ -208,7 +218,7 @@ kubectl create namespace demo
208218
We will now create two pods in the cluster named *client* and *server*.
209219

210220
>[!NOTE]
211-
> If you want to schedule the *client* or *server* on a particular node, add the following bit before the *--comand* argument in the pod creation [kubectl run][kubectl-run] command:
221+
> 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:
212222
213223
> ```console
214224
>--overrides='{"spec": { "nodeSelector": {"kubernetes.io/os": "linux|windows"}}}'
@@ -219,7 +229,7 @@ Create a *server* pod. This pod will serve on TCP port 80:
219229
kubectl run server -n demo --image=k8s.gcr.io/e2e-test-images/agnhost:2.33 --labels="app=server" --port=80 --command -- /agnhost serve-hostname --tcp --http=false --port "80"
220230
```
221231
222-
Create a *client* pod:
232+
Create a *client* pod. The below command will run bash on the client pod:
223233

224234
```console
225235
kubectl run -it client -n demo --image=k8s.gcr.io/e2e-test-images/agnhost:2.33 --command -- bash
@@ -246,7 +256,7 @@ In the client's shell, verify connectivity with the server by executing the foll
246256

247257
### Test Connectivity with Network Policy
248258

249-
Create a file named demo-pods-policy.yaml and paste the following YAML manifest to add network policies:
259+
Create a file named demo-policy.yaml and paste the following YAML manifest to add network policies:
250260

251261
```yaml
252262
apiVersion: networking.k8s.io/v1
@@ -270,7 +280,7 @@ spec:
270280
Specify the name of your YAML manifest and apply it using [kubectl apply][kubectl-apply]:
271281
272282
```console
273-
kubectl apply –f demo-pods.yaml
283+
kubectl apply –f demo-policy.yaml
274284
```
275285

276286
Now, in the client's shell, verify connectivity with the server by executing the following `/agnhost` command:
@@ -279,21 +289,21 @@ Now, in the client's shell, verify connectivity with the server by executing the
279289
/agnhost connect <server-ip>:80 --timeout=3s --protocol=tcp
280290
```
281291

282-
Connectivity 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:
292+
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:
283293

284294
```output
285295
TIMEOUT
286296
```
287297

288-
Run the following command to label the *client* and retry verifying connectivity with the server. The output should return noting, in case of success.
298+
Run the following command to label the *client* and verify connectivity with the server (output should return nothing).
289299

290300
```console
291301
kubectl label pod client -n demo app=client
292302
```
293303

294304
## Clean up resources
295305

296-
In this article, we created a namespace, two pods and applied a Network Policy. To clean up these resources, use the [kubectl delete][kubectl-delete] command and specify the resource name:
306+
In this article, we created a namespace and two pods and applied a Network Policy. To clean up these resources, use the [kubectl delete][kubectl-delete] command and specify the resource name:
297307

298308
```console
299309
kubectl delete namespace demo

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ See a [configuration for these alerts](#setup-alerts-for-alertmanager) below.
7474
2. Alert when the median time to apply changes for a create event was more than 100 milliseconds.
7575

7676
##### Visualizations and Debugging via our Grafana Dashboard or Azure Monitor Workbook
77-
1. See how many iptables rules your policies create (having a massive amount of iptables rules may increase latency slightly).
77+
1. See how many IPTables rules your policies create (having a massive amount of IPTables rules may increase latency slightly).
7878
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").
79+
3. Get the human-friendly name of an ipset in a given IPTables rule (e.g. "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.
@@ -97,16 +97,16 @@ The following is the list of supported metrics. Any `quantile` label has possibl
9797

9898
There are also "exec_time_count" and "exec_time_sum" metrics for each "exec_time" Summary metric.
9999

100-
The metrics can be scraped through Azure Monitor for Containers or through Prometheus.
100+
The metrics can be scraped through Azure Monitor for containers or through Prometheus.
101101

102102
### Setup for Azure Monitor
103-
The first step is to enable Azure Monitor for containers for your Kubernetes cluster. Steps can be found in [Azure Monitor for containers Overview](../azure-monitor/containers/container-insights-overview.md). Once you have Azure Monitor for containers enabled, configure the [Azure Monitor for containers ConfigMap](https://aka.ms/container-azm-ms-agentconfig) to enable NPM integration and collection of Prometheus NPM metrics. Azure monitor for containers ConfigMap has an ```integrations``` section with settings to collect NPM metrics. These settings are disabled by default in the ConfigMap. Enabling the basic setting ```collect_basic_metrics = true```, will collect basic NPM metrics. Enabling advanced setting ```collect_advanced_metrics = true``` will collect advanced metrics in addition to basic metrics.
103+
The first step is to enable Azure Monitor for containers for your Kubernetes cluster. Steps can be found in [Azure Monitor for containers Overview](../azure-monitor/containers/container-insights-overview.md). Once you have Azure Monitor for containers enabled, configure the [Azure Monitor for containers ConfigMap](https://aka.ms/container-azm-ms-agentconfig) to enable NPM integration and collection of Prometheus NPM metrics. Azure Monitor for containers ConfigMap has an ```integrations``` section with settings to collect NPM metrics. These settings are disabled by default in the ConfigMap. Enabling the basic setting ```collect_basic_metrics = true```, will collect basic NPM metrics. Enabling advanced setting ```collect_advanced_metrics = true``` will collect advanced metrics in addition to basic metrics.
104104

105105
After editing the ConfigMap, save it locally and apply the ConfigMap to your cluster as follows.
106106

107107
`kubectl apply -f container-azm-ms-agentconfig.yaml`
108108

109-
Below is a snippet from the [Azure monitor for containers ConfigMap](https://aka.ms/container-azm-ms-agentconfig), which shows the NPM integration enabled with advanced metrics collection.
109+
Below is a snippet from the [Azure Monitor for containers ConfigMap](https://aka.ms/container-azm-ms-agentconfig), which shows the NPM integration enabled with advanced metrics collection.
110110
```
111111
integrations: |-
112112
[integrations.azure_network_policy_manager]
@@ -115,7 +115,7 @@ integrations: |-
115115
```
116116
Advanced metrics are optional, and turning them on will automatically turn on basic metrics collection. Advanced metrics currently include only `npm_ipset_counts`
117117

118-
Learn more about [Azure monitor for containers collection settings in config map](../azure-monitor/containers/container-insights-agent-config.md)
118+
Learn more about [Azure Monitor for containers collection settings in config map](../azure-monitor/containers/container-insights-agent-config.md)
119119

120120
### Visualization Options for Azure Monitor
121121
Once NPM metrics collection is enabled, you can view the metrics in the Azure portal using Container Insights or in Grafana.

0 commit comments

Comments
 (0)