Azure CNI vs Kubenet, What are the differences between them and which one to use?
if you have ever deployed an AKS cluster, either through the Azure Portal or CLI, there is parameter that needs to be configured related to the networking part of AKS and that is to choose the networking model between Azure CNI and Kubenet. (by default it's Kubenet as of writing this post)
So what's this all about? in a nutshell this parameter is related to how Nodes and Pods gets their IP addresses assigned. It\s important to understand their difference before creating the cluster since you can\t change the networking model of your cluster once it\s deployed, and you defiantly don't want to re-create and re-configure your cluster again just because of this option.
Overview of Kubenet and a few things to keep in mind
- This is the default options if you don't explicitly change it. With this option the cluster nodes gets their IP addresses from the VNET which your AKS is deployed to. This is not a big deal since the same thing happens if you go with the second option, AKA, CNI. BUT, in this mode the PODS gets their ip addresses from a logically different address space than your VNET, and Pods can access resources in the VNET via NAT which takes place through the Node where the Pods is running.
- It is also worth knowing that in this mode "Pods can't communicate directly with each other. Instead User Defined Routing (UDR) and IP forwarding is used for connectivity between pods across nodes." (taken from MS official docs)
- Also, in this mode you can only have ONE AKS cluster in each Subnet.
- There will be an additional latency between Pods communication due to extra hop. but the difference is sub-millisecond.
- The default number of Pods per node is 110.
![]() |
| Kubenet overview, taken from Microsoft.com |
Overview of Azure CNI Option and a few things to keep in mind
On the contrary, if you choose Azure CNI over Kubenet, your Pods gets their IP addresses directly from the Subnet, and can access all the resources in the subnet without the needs of NATing via the Cluster Node. in another word, in this mod, each Pod has full connectivity to the Vnet out of the box.
![]() |
| Azure CNI Network Model, taken from Microsoft.com |
Azure CNI is a more advanced option, and requires additional preparation by ensuring that your VNet and Subnet is large enough to accommodate the number of Nodes, and the number of Pods in each node.
I prefer not to write much about how you should plan your Vnet and Subnet sizing before creating your cluster, because that itself can be a great topic for another article, but rather I want to emphasize on two things:
- Keep in mind that the maximum number of Pods per node is 30 by default. You can increase this number when creating the cluster, but you can NOT change the number once your cluster gets created.
- Try to be safe that sorry by making sure that your Subnet is large enough not for your current workload but for months and possibly year to come. I myself once deployed an AKS cluster to a
Which one to choose?
Now comes the question you might be pondering upon, and that is which one to choose? In short, I ALWAYS recommend Azure CNI for any production workload; despite the fact that it comes with additional complexity to begin with. Kubenet is a very basic network plugin that doesn't scale much nor it supports any advance network routing and traffic management. if you happen to run single node cluster then using Azure CNI would be an overkill, and you are better-off to go with Kubenet.


Comments
Post a Comment