Skip to content

Commit 1a8ee00

Browse files
authored
Merge pull request #223423 from schaffererin/aks-az-cni-rearchitect
AKS - Rearchitect long docs: Configure Azure CNI networking in AKS
2 parents edb87e6 + c0ed6d3 commit 1a8ee00

File tree

4 files changed

+165
-134
lines changed

4 files changed

+165
-134
lines changed

articles/aks/TOC.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,11 @@
376376
href: use-byo-cni.md
377377
- name: Use Azure CNI Powered by Cilium (Preview)
378378
href: azure-cni-powered-by-cilium.md
379-
- name: Use Azure-CNI
379+
- name: Use Azure CNI
380380
href: configure-azure-cni.md
381-
- name: Use Azure-CNI Overlay (Preview)
381+
- name: Use Azure CNI for dynamic IP allocation and enhanced subnet support
382+
href: configure-azure-cni-dynamic-ip-allocation.md
383+
- name: Use Azure CNI Overlay (Preview)
382384
href: azure-cni-overlay.md
383385
- name: DNS
384386
items:
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: Configure Azure CNI networking for dynamic allocation of IPs and enhanced subnet support in Azure Kubernetes Service (AKS)
3+
description: Learn how to configure Azure CNI (advanced) networking for dynamic allocation of IPs and enhanced subnet support in Azure Kubernetes Service (AKS)
4+
services: container-service
5+
ms.topic: article
6+
ms.date: 01/09/2023
7+
ms.custom: references_regions, devx-track-azurecli
8+
---
9+
10+
# Configure Azure CNI networking for dynamic allocation of IPs and enhanced subnet support in Azure Kubernetes Service (AKS)
11+
12+
A drawback with the traditional CNI is the exhaustion of pod IP addresses as the AKS cluster grows, which results in the need to rebuild your entire cluster in a bigger subnet. The new dynamic IP allocation capability in Azure CNI solves this problem by allocating pod IPs from a subnet separate from the subnet hosting the AKS cluster.
13+
14+
It offers the following benefits:
15+
16+
* **Better IP utilization**: IPs are dynamically allocated to cluster Pods from the Pod subnet. This leads to better utilization of IPs in the cluster compared to the traditional CNI solution, which does static allocation of IPs for every node.
17+
* **Scalable and flexible**: Node and pod subnets can be scaled independently. A single pod subnet can be shared across multiple node pools of a cluster or across multiple AKS clusters deployed in the same VNet. You can also configure a separate pod subnet for a node pool.
18+
* **High performance**: Since pod are assigned VNet IPs, they have direct connectivity to other cluster pod and resources in the VNet. The solution supports very large clusters without any degradation in performance.
19+
* **Separate VNet policies for pods**: Since pods have a separate subnet, you can configure separate VNet policies for them that are different from node policies. This enables many useful scenarios such as allowing internet connectivity only for pods and not for nodes, fixing the source IP for pod in a node pool using a VNet Network NAT, and using NSGs to filter traffic between node pools.
20+
* **Kubernetes network policies**: Both the Azure Network Policies and Calico work with this new solution.
21+
22+
This article shows you how to use Azure CNI networking for dynamic allocation of IPs and enhanced subnet support in AKS.
23+
24+
## Prerequisites
25+
26+
> [!NOTE]
27+
> When using dynamic allocation of IPs, exposing an application as a Private Link Service using a Kubernetes Load Balancer Service isn't supported.
28+
29+
* Review the [prerequisites](/configure-azure-cni.md#prerequisites) for configuring basic Azure CNI networking in AKS, as the same prerequisites apply to this article.
30+
* Review the [deployment parameters](/configure-azure-cni.md#deployment-parameters) for configuring basic Azure CNI networking in AKS, as the same parameters apply.
31+
* Only linux node clusters and node pools are supported.
32+
* AKS Engine and DIY clusters aren't supported.
33+
* Azure CLI version `2.37.0` or later.
34+
35+
## Plan IP addressing
36+
37+
Planning your IP addressing is much simpler with this feature. Since the nodes and pods scale independently, their address spaces can also be planned separately. Since pod subnets can be configured to the granularity of a node pool, you can always add a new subnet when you add a node pool. The system pods in a cluster/node pool also receive IPs from the pod subnet, so this behavior needs to be accounted for.
38+
39+
IPs are allocated to nodes in batches of 16. Pod subnet IP allocation should be planned with a minimum of 16 IPs per node in the cluster; nodes will request 16 IPs on startup and will request another batch of 16 any time there are <8 IPs unallocated in their allotment.
40+
41+
The planning of IPs for Kubernetes services and Docker bridge remain unchanged.
42+
43+
## Maximum pods per node in a cluster with dynamic allocation of IPs and enhanced subnet support
44+
45+
The pods per node values when using Azure CNI with dynamic allocation of IPs slightly differ from the traditional CNI behavior:
46+
47+
|CNI|Default|Configurable at deployment|
48+
|--| :--: |--|
49+
|Traditional Azure CNI|30|Yes (up to 250)|
50+
|Azure CNI with dynamic allocation of IPs|250|Yes (up to 250)|
51+
52+
All other guidance related to configuring the maximum pods per node remains the same.
53+
54+
## Deployment parameters
55+
56+
The [deployment parameters](/configure-azure-cni.md#deployment-parameters) for configuring basic Azure CNI networking in AKS are all valid, with two exceptions:
57+
58+
* The **subnet** parameter now refers to the subnet related to the cluster's nodes.
59+
* An additional parameter **pod subnet** is used to specify the subnet whose IP addresses will be dynamically allocated to pods.
60+
61+
## Configure networking with dynamic allocation of IPs and enhanced subnet support - Azure CLI
62+
63+
Using dynamic allocation of IPs and enhanced subnet support in your cluster is similar to the default method for configuring a cluster Azure CNI. The following example walks through creating a new virtual network with a subnet for nodes and a subnet for pods, and creating a cluster that uses Azure CNI with dynamic allocation of IPs and enhanced subnet support. Be sure to replace variables such as `$subscription` with your own values.
64+
65+
Create the virtual network with two subnets.
66+
67+
```azurecli-interactive
68+
resourceGroup="myResourceGroup"
69+
vnet="myVirtualNetwork"
70+
location="westcentralus"
71+
72+
# Create the resource group
73+
az group create --name $resourceGroup --location $location
74+
75+
# Create our two subnet network
76+
az network vnet create -g $resourceGroup --location $location --name $vnet --address-prefixes 10.0.0.0/8 -o none
77+
az network vnet subnet create -g $resourceGroup --vnet-name $vnet --name nodesubnet --address-prefixes 10.240.0.0/16 -o none
78+
az network vnet subnet create -g $resourceGroup --vnet-name $vnet --name podsubnet --address-prefixes 10.241.0.0/16 -o none
79+
```
80+
81+
Create the cluster, referencing the node subnet using `--vnet-subnet-id` and the pod subnet using `--pod-subnet-id`.
82+
83+
```azurecli-interactive
84+
clusterName="myAKSCluster"
85+
subscription="aaaaaaa-aaaaa-aaaaaa-aaaa"
86+
87+
az aks create -n $clusterName -g $resourceGroup -l $location \
88+
--max-pods 250 \
89+
--node-count 2 \
90+
--network-plugin azure \
91+
--vnet-subnet-id /subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnet/subnets/nodesubnet \
92+
--pod-subnet-id /subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnet/subnets/podsubnet
93+
```
94+
95+
### Adding node pool
96+
97+
When adding node pool, reference the node subnet using `--vnet-subnet-id` and the pod subnet using `--pod-subnet-id`. The following example creates two new subnets that are then referenced in the creation of a new node pool:
98+
99+
```azurecli-interactive
100+
az network vnet subnet create -g $resourceGroup --vnet-name $vnet --name node2subnet --address-prefixes 10.242.0.0/16 -o none
101+
az network vnet subnet create -g $resourceGroup --vnet-name $vnet --name pod2subnet --address-prefixes 10.243.0.0/16 -o none
102+
103+
az aks nodepool add --cluster-name $clusterName -g $resourceGroup -n newnodepool \
104+
--max-pods 250 \
105+
--node-count 2 \
106+
--vnet-subnet-id /subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnet/subnets/node2subnet \
107+
--pod-subnet-id /subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Network/virtualNetworks/$vnet/subnets/pod2subnet \
108+
--no-wait
109+
```
110+
111+
## Dynamic allocation of IP addresses and enhanced subnet support FAQs
112+
113+
* **Can I assign multiple pod subnets to a cluster/node pool?**
114+
115+
Only one subnet can be assigned to a cluster or node pool. However, multiple clusters or node pools can share a single subnet.
116+
117+
* **Can I assign Pod subnets from a different VNet altogether?**
118+
119+
No, the pod subnet should be from the same VNet as the cluster.
120+
121+
* **Can some node pools in a cluster use the traditional CNI while others use the new CNI?**
122+
123+
The entire cluster should use only one type of CNI.
124+
125+
## Next steps
126+
127+
Learn more about networking in AKS in the following articles:
128+
129+
* [Use a static IP address with the Azure Kubernetes Service (AKS) load balancer](static-ip.md)
130+
* [Use an internal load balancer with Azure Kubernetes Service (AKS)](internal-lb.md)
131+
132+
* [Create a basic ingress controller with external network connectivity][aks-ingress-basic]
133+
* [Enable the HTTP application routing add-on][aks-http-app-routing]
134+
* [Create an ingress controller that uses an internal, private network and IP address][aks-ingress-internal]
135+
* [Create an ingress controller with a dynamic public IP and configure Let's Encrypt to automatically generate TLS certificates][aks-ingress-tls]
136+
* [Create an ingress controller with a static public IP and configure Let's Encrypt to automatically generate TLS certificates][aks-ingress-static-tls]
137+
138+
<!-- LINKS - Internal -->
139+
[aks-ingress-basic]: ingress-basic.md
140+
[aks-ingress-tls]: ingress-tls.md
141+
[aks-ingress-static-tls]: ingress-static-ip.md
142+
[aks-http-app-routing]: http-application-routing.md
143+
[aks-ingress-internal]: ingress-internal-ip.md

0 commit comments

Comments
 (0)