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
+32-22Lines changed: 32 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,16 +24,16 @@ All pods in an AKS cluster can send and receive traffic without limitations, by
24
24
25
25
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.
26
26
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.
28
28
29
29
## Network policy options in AKS
30
30
31
31
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:
32
32
33
-
* Azure's own implementation, called *Azure Network Policy Manager(NPM)*.
33
+
* Azure's own implementation, called *Azure Network Policy Manager(NPM)*.
34
34
**Calico Network Policies*, an open-source network and network security solution founded by [Tigera][tigera].
35
35
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.
37
37
38
38
## Differences between Azure NPM and Calico Network Policy and their capabilities
39
39
@@ -48,7 +48,7 @@ Azure NPM for Linux uses Linux *IPTables* and Azure NPM for Windows uses *Host N
48
48
49
49
## Limitations:
50
50
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.
52
52
* In Windows, Azure NPM does not support the following:
53
53
* named ports
54
54
* SCTP protocol
@@ -111,6 +111,7 @@ Please execute the following commands prior to creating a cluster:
111
111
az feature register --namespace Microsoft.ContainerService --name AKSWindows2022Preview
112
112
az feature register --namespace Microsoft.ContainerService --name WindowsNetworkPolicyPreview
113
113
az provider register -n Microsoft.ContainerService
114
+
```
114
115
115
116
> [!NOTE]
116
117
> At this time, Azure NPM with Windows nodes is available on Windows Server 2022 only
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:
130
138
131
139
```azurecli
132
140
az aks create \
@@ -141,9 +149,16 @@ az aks create \
141
149
--node-count 1
142
150
```
143
151
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
+
```
147
162
148
163
[!INCLUDE [preview features callout](./includes/preview/preview-callout.md)]
149
164
@@ -185,19 +200,14 @@ az aks nodepool add \
185
200
--node-count 1
186
201
```
187
202
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
-
```
193
203
## Verify Network Policy Setup
194
204
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:
196
206
197
207
```azurecli-interactive
198
208
az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $CLUSTER_NAME
199
209
```
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.
201
211
202
212
Firstly, let's create a namespace called *demo* to run the example pods:
203
213
@@ -208,7 +218,7 @@ kubectl create namespace demo
208
218
We will now create two pods in the cluster named *client* and *server*.
209
219
210
220
>[!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:
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:
283
293
284
294
```output
285
295
TIMEOUT
286
296
```
287
297
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).
289
299
290
300
```console
291
301
kubectl label pod client -n demo app=client
292
302
```
293
303
294
304
## Clean up resources
295
305
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:
Copy file name to clipboardExpand all lines: articles/virtual-network/kubernetes-network-policies.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,9 +74,9 @@ See a [configuration for these alerts](#setup-alerts-for-alertmanager) below.
74
74
2. Alert when the median time to apply changes for a create event was more than 100 milliseconds.
75
75
76
76
##### 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).
78
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").
79
+
3. Get the human-friendly name of an ipset in a given IPTables rule (e.g. "azure-npm-487392" represents "podlabel-role:database").
80
80
81
81
### All supported metrics
82
82
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
97
97
98
98
There are also "exec_time_count" and "exec_time_sum" metrics for each "exec_time" Summary metric.
99
99
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.
101
101
102
102
### 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.
104
104
105
105
After editing the ConfigMap, save it locally and apply the ConfigMap to your cluster as follows.
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.
110
110
```
111
111
integrations: |-
112
112
[integrations.azure_network_policy_manager]
@@ -115,7 +115,7 @@ integrations: |-
115
115
```
116
116
Advanced metrics are optional, and turning them on will automatically turn on basic metrics collection. Advanced metrics currently include only `npm_ipset_counts`
117
117
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)
119
119
120
120
### Visualization Options for Azure Monitor
121
121
Once NPM metrics collection is enabled, you can view the metrics in the Azure portal using Container Insights or in Grafana.
0 commit comments