Skip to content

Commit 14caeba

Browse files
Merge pull request #265359 from robogatikov/robogatikov/network-policies
update use-network-policies.md to include Uninstall NPM section
2 parents b987118 + fa4d70f commit 14caeba

File tree

5 files changed

+85
-28
lines changed

5 files changed

+85
-28
lines changed

articles/aks/azure-cni-overlay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ az aks nodepool add -g $resourceGroup --cluster-name $clusterName \
138138
>
139139
> - The cluster is on Kubernetes version 1.22+.
140140
> - Doesn't use the dynamic pod IP allocation feature.
141-
> - Doesn't have network policies enabled.
141+
> - Doesn't have network policies enabled. Network Policy engine can be uninstalled before the upgrade, see [Uninstall Azure Network Policy Manager or Calico](use-network-policies.md#uninstall-azure-network-policy-manager-or-calico-preview)
142142
> - Doesn't use any Windows node pools with docker as the container runtime.
143143
144144
> [!NOTE]

articles/aks/azure-cni-powered-by-cilium.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ az aks create -n <clusterName> -g <resourceGroupName> -l <location> \
116116
> You can update an existing cluster to Azure CNI Powered by Cilium if the cluster meets the following criteria:
117117
>
118118
> - The cluster uses either [Azure CNI Overlay](./azure-cni-overlay.md) or [Azure CNI with dynamic IP allocation](./configure-azure-cni-dynamic-ip-allocation.md). This does **not** include [Azure CNI](./configure-azure-cni.md).
119-
> - The cluster does not have Azure NPM or Calico enabled.
120-
> - The cluster does not have any Windows node pools.
119+
> - The cluster does not have any Windows node pools.
121120
122-
The upgrade process triggers each node pool to be re-imaged simultaneously. Upgrading each node pool separately isn't supported. Any disruptions to cluster networking are similar to a node image upgrade or [Kubernetes version upgrade](./upgrade-cluster.md) where each node in a node pool is re-imaged.
121+
> [!NOTE]
122+
> When enabling Cilium in a cluster with a different network policy engine (Azure NPM or Calico), the network policy engine will be uninstalled and replaced with Cilium. See [Uninstall Azure Network Policy Manager or Calico](./use-network-policies.md#uninstall-azure-network-policy-manager-or-calico-preview) for more details.
123+
124+
> [!WARNING]
125+
> The upgrade process triggers each node pool to be re-imaged simultaneously. Upgrading each node pool separately isn't supported. Any disruptions to cluster networking are similar to a node image upgrade or [Kubernetes version upgrade](./upgrade-cluster.md) where each node in a node pool is re-imaged.
123126
124127
Cilium will begin enforcing network policies only after all nodes have been re-imaged.
125128

@@ -132,6 +135,7 @@ az aks update -n <clusterName> -g <resourceGroupName> \
132135
--network-dataplane cilium
133136
```
134137

138+
135139
## Frequently asked questions
136140

137141
- **Can I customize Cilium configuration?**

articles/aks/support-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Microsoft provides technical support for the following examples:
5858
* Connectivity to other Azure services and applications
5959
* Ingress controllers and ingress or load balancer configurations
6060
* Network performance and latency
61-
* [Network policies](use-network-policies.md#compare-azure-network-policy-manager-and-calico-network-policy)
61+
* [Network policies](use-network-policies.md#differences-between-network-policy-engines-cilium-azure-npm-and-calico)
6262

6363
> [!NOTE]
6464
> Any cluster actions taken by Microsoft/AKS are made with your consent under a built-in Kubernetes role `aks-service` and built-in role binding `aks-service-rolebinding`. This role enables AKS to troubleshoot and diagnose cluster issues, but can't modify permissions nor create roles or role bindings, or other high privilege actions. Role access is only enabled under active support tickets with just-in-time (JIT) access.

articles/aks/use-network-policies.md

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,28 @@ This article shows you how to install the network policy engine and create Kuber
1717

1818
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].
1919

20+
### Uninstall Azure Network Policy Manager or Calico (Preview)
21+
Requirements:
22+
- aks-preview Azure CLI extension version 0.5.166 or later. See [Install the aks-preview Azure CLI extension](#install-the-aks-preview-azure-cli-extension).
23+
- Azure CLI version 2.54 or later
24+
- AKS REST API version 2023-08-02-preview or later
25+
26+
Notes:
27+
- The uninstall process does _not_ remove Custom Resource Definitions (CRDs) and Custom Resources (CRs) used by Calico. These CRDs and CRs all have names ending with either "projectcalico.org" or "tigera.io".
28+
These CRDs and associated CRs can be manually deleted _after_ Calico is successfully uninstalled (deleting the CRDs before removing Calico breaks the cluster).
29+
- The upgrade will not remove any NetworkPolicy resources in the cluster, but after the uninstall these policies are no longer enforced.
30+
31+
> [!WARNING]
32+
> The upgrade process triggers each node pool to be re-imaged simultaneously. Upgrading each node pool separately isn't supported. Any disruptions to cluster networking are similar to a node image upgrade or [Kubernetes version upgrade](./upgrade-cluster.md) where each node in a node pool is re-imaged.
33+
34+
To remove Azure Network Policy Manager or Calico from a cluster, run the following command:
35+
```azurecli
36+
az aks update
37+
--resource-group $RESOURCE_GROUP_NAME \
38+
--name $CLUSTER_NAME \
39+
--network-policy none
40+
```
41+
2042
## Overview of network policy
2143

2244
All pods in an AKS cluster can send and receive traffic without limitations, by default. To improve security, you can define rules that control the flow of traffic. Back-end applications are often only exposed to required front-end services, for example. Or, database components are only accessible to the application tiers that connect to them.
@@ -27,23 +49,25 @@ The network policy rules are defined as YAML manifests. Network policies can be
2749

2850
## Network policy options in AKS
2951

30-
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. The options are:
52+
Azure provides three Network Policy engines for enforcing network policies:
3153

32-
- **Azure Network Policy Manager**: The implementation in Azure.
33-
- **Calico network policy**: An open-source network and network security solution founded by [Tigera][tigera].
54+
* *Cilium* for AKS clusters that use [Azure CNI Powered by Cilium](./azure-cni-powered-by-cilium.md).
55+
* *Azure Network Policy Manager*.
56+
* *Calico*, an open-source network and network security solution founded by [Tigera][tigera].
3457

58+
Cilium is our recommended Network Policy engine. Cilium enforces network policy on the traffic using Linux Berkeley Packet Filter (BPF), which is generally more efficient than "IPTables". See more details in [Azure CNI Powered by Cilium documentation](./azure-cni-powered-by-cilium.md).
3559
To enforce the specified policies, Azure Network Policy Manager for Linux uses Linux *IPTables*. Azure Network Policy Manager for Windows uses *Host Network Service (HNS) ACLPolicies*. Policies are translated into sets of allowed and disallowed IP pairs. These pairs are then programmed as `IPTable` or `HNS ACLPolicy` filter rules.
3660

37-
## Compare Azure Network Policy Manager and Calico network policy
3861

39-
| Capability | Azure Network Policy Manager | Calico network policy |
40-
|------------------------------------------|----------------------------|-----------------------------|
41-
| Supported platforms | Linux, Windows Server 2022. | Linux, Windows Server 2019 and 2022. |
42-
| Supported networking options | Azure Container Networking Interface (CNI). | Azure CNI (Linux, Windows Server 2019 and 2022) and kubenet (Linux). |
43-
| Compliance with Kubernetes specification | All policy types are supported. | All policy types are supported. |
44-
| Other 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]. |
45-
| Support | Supported by Azure Support and Engineering team. | Calico community support. For more information on more paid support, see [Project Calico support options][calico-support]. |
46-
| Logging | Logs are available with the `kubectl log -n kube-system \<network-policy-pod\>` command. | For more information, see [Calico component logs][calico-logs]. |
62+
## Differences between Network Policy engines: Cilium, Azure NPM, and Calico
63+
64+
| Capability | Azure Network Policy Manager | Calico | Cilium
65+
|------------------------------------------|-------------------------------------------------|----------------------------|----------------------------------------------------|
66+
| Supported platforms | Linux, Windows Server 2022 (Preview). | Linux, Windows Server 2019 and 2022. | Linux.
67+
| Supported networking options | Azure Container Networking Interface (CNI). | Azure CNI (Linux, Windows Server 2019 and 2022) and kubenet (Linux). | Azure CNI.
68+
| Compliance with Kubernetes specification | All policy types supported | All policy types are supported. | All policy types are supported.
69+
| Other 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]. | None.
70+
| Support | Supported by Azure Support and Engineering team. | Supported by Azure Support and Engineering team. | Supported by Azure Support and Engineering team.
4771

4872
## Limitations
4973

@@ -68,15 +92,12 @@ With Azure Network Policy Manager for Linux, we don't allow scaling beyond 250 n
6892

6993
To see network policies in action, you create an AKS cluster that supports network policy and then work on adding policies.
7094

71-
> [!IMPORTANT]
72-
>
73-
> The network policy feature can only be enabled when the cluster is created. You can't enable network policy on an existing AKS cluster.
74-
75-
To use Azure Network Policy Manager, 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 Kubernetes CNI plug-in.
95+
To use Azure Network Policy Manager, you must use the Azure CNI plug-in. Calico can be used with either Azure CNI plug-in or with the Kubenet CNI plug-in.
7696

7797
The following example script creates an AKS cluster with system-assigned identity and enables network policy by using Azure Network Policy Manager.
7898

79-
To use Calico as the network policy option instead, use the `--network-policy calico` parameter. Calico could be used with either `--network-plugin azure` or `--network-plugin kubenet`.
99+
>[!Note}
100+
> Calico can be used with either the `--network-plugin azure` or `--network-plugin kubenet` parameters.
80101
81102
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).
82103

@@ -189,9 +210,9 @@ az aks nodepool add \
189210
--node-count 1
190211
```
191212

192-
### Create an AKS cluster for Calico network policy
213+
### Create an AKS cluster with Calico enabled
193214

194-
Create the AKS cluster and specify `azure` for the network plug-in and `calico` for the network policy. When you use `calico` as the network policy, Calico networking is enabled on both Linux and Windows node pools.
215+
Create the AKS cluster and specify `--network-plugin azure`, and `--network-policy calico`. Specifying `--network-policy calico` enables Calico on both Linux and Windows node pools.
195216

196217
If you plan on adding Windows node pools to your cluster, include the `windows-admin-username` and `windows-admin-password` parameters that meet the [Windows Server password requirements][windows-server-password].
197218

@@ -227,6 +248,38 @@ az aks nodepool add \
227248
--node-count 1
228249
```
229250

251+
## Install Azure Network Policy Manager or Calico in an existing cluster
252+
Installing Azure Network Policy Manager or Calico on existing AKS clusters is also supported.
253+
> [!WARNING]
254+
> The upgrade process triggers each node pool to be re-imaged simultaneously. Upgrading each node pool separately isn't supported. Any disruptions to cluster networking are similar to a node image upgrade or [Kubernetes version upgrade](./upgrade-cluster.md) where each node in a node pool is re-imaged.
255+
256+
Example command to install Azure Network Policy Manager:
257+
```azurecli
258+
az aks update
259+
--resource-group $RESOURCE_GROUP_NAME \
260+
--name $CLUSTER_NAME \
261+
--network-policy azure
262+
```
263+
264+
Example command to install Calico:
265+
> [!WARNING]
266+
> This warning applies to upgrading Kubenet clusters with Calico enabled to Azure CNI Overlay with Calico enabled.
267+
> - In Kubenet clusters with Calico enabled, Calico is used as both a CNI and network policy engine.
268+
> - In Azure CNI clusters, Calico is used only for network policy enforcement, not as a CNI. This can cause a short delay between when the pod starts and when Calico allows outbound traffic from the pod.
269+
>
270+
> It is recommended to use Cilium instead of Calico to avoid this issue. Learn more about Cilium at [Azure CNI Powered by Cilium](./azure-cni-powered-by-cilium.md)
271+
>
272+
273+
```azurecli
274+
az aks update
275+
--resource-group $RESOURCE_GROUP_NAME \
276+
--name $CLUSTER_NAME \
277+
--network-policy calico
278+
```
279+
280+
## Upgrade an existing cluster that has Azure NPM or Calico installed to Azure CNI Powered by Cilium
281+
To upgrade an existing cluster that has Network Policy engine installed to Azure CNI Powered by Cilium, see [Upgrade an existing cluster to Azure CNI Powered by Cilium](azure-cni-powered-by-cilium.md#upgrade-an-existing-cluster-to-azure-cni-powered-by-cilium)
282+
230283
## Verify network policy setup
231284

232285
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:
@@ -286,7 +339,7 @@ In the client's shell, run the following command to verify connectivity with the
286339

287340
### Test connectivity with network policy
288341

289-
Create a file named `demo-policy.yaml` and paste the following YAML manifest to add network policies:
342+
To add network policies create a file named `demo-policy.yaml` and paste the following YAML manifest:
290343

291344
```yaml
292345
apiVersion: networking.k8s.io/v1

articles/aks/windows-best-practices.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ To help you decide which networking mode to use, see [Choosing a network model][
5757

5858
> **Best practice guidance**
5959
>
60-
> Use network policies to secure traffic between pods. Windows supports Azure Network Policy Manager and Calico Network Policy. For more information, see [Differences between Azure Network Policy Manager and Calico Network Policy][azurenpm-vs-calico].
60+
> Use network policies to secure traffic between pods. Windows supports Azure Network Policy Manager and Calico Network Policy. For more information, see [Differences between Network Policy engines: Cilium, Azure NPM, and Calico][azurenpm-vs-calico].
6161
6262
When managing traffic between pods, you should apply the principle of least privilege. The Network Policy feature in Kubernetes allows you to define and enforce ingress and egress traffic rules between the pods in your cluster. For more information, see [Secure traffic between pods using network policies in AKS][network-policies-aks].
6363

@@ -111,7 +111,7 @@ To learn more about Windows containers on AKS, see the following resources:
111111
[azure-cni-choose-network-model]: ./azure-cni-overlay.md#choosing-a-network-model-to-use
112112
[network-concepts-for-aks-applications]: ./concepts-network.md
113113
[windows-vs-linux]: ./windows-vs-linux-containers.md
114-
[azurenpm-vs-calico]: ./use-network-policies.md#compare-azure-network-policy-manager-and-calico-network-policy
114+
[azurenpm-vs-calico]: ./use-network-policies.md#differences-between-network-policy-engines-cilium-azure-npm-and-calico
115115
[network-policies-aks]: ./use-network-policies.md
116116
[dsr]: ../load-balancer/load-balancer-multivip-overview.md#rule-type-2-backend-port-reuse-by-using-floating-ip
117117
[upgrade-aks-cluster]: ./upgrade-cluster.md

0 commit comments

Comments
 (0)