AKS networking (kubenet, Azure CNI) - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
We want to understand how the time to set up networking in AKS changes as the number of nodes or pods grows.
Specifically, how does the choice between kubenet and Azure CNI affect this growth?
Analyze the time complexity of pod IP assignment during AKS cluster scaling.
// Example: Assign IPs to pods when nodes are added
for each node in cluster {
for each pod on node {
assign IP address using network plugin
}
}
This sequence shows how IP addresses are assigned to pods on each node using either kubenet or Azure CNI.
Look at what repeats as the cluster grows:
- Primary operation: Assigning IP addresses to pods via network plugin calls.
- How many times: Once per pod, across all nodes.
As you add more nodes and pods, the number of IP assignments grows.
| Input Size (pods) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 IP assignments |
| 100 | 100 IP assignments |
| 1000 | 1000 IP assignments |
Pattern observation: The number of IP assignments grows directly with the number of pods.
Time Complexity: O(n)
This means the time to assign IPs grows linearly with the number of pods in the cluster.
[X] Wrong: "Adding more nodes does not affect IP assignment time because nodes work independently."
[OK] Correct: Even if nodes work independently, each pod still needs an IP assigned, so total work grows with total pods.
Understanding how network setup scales helps you design efficient clusters and troubleshoot performance as they grow.
What if the network plugin cached IP assignments instead of assigning them each time? How would the time complexity change?
Practice
kubenet and Azure CNI networking in AKS?Solution
Step 1: Understand kubenet networking
Kubenet assigns pod IPs from a private IP range and uses NAT to allow pods to communicate outside the cluster.Step 2: Understand Azure CNI networking
Azure CNI assigns pod IPs directly from the Azure virtual network subnet, allowing pods to have direct IP addresses visible in the Azure network.Final Answer:
Kubenet uses NAT and assigns pod IPs from a private range, Azure CNI assigns IPs from the Azure subnet directly. -> Option BQuick Check:
Kubenet = NAT, Azure CNI = Azure subnet IPs [OK]
- Confusing which method uses NAT
- Thinking both assign IPs from Azure subnet
- Assuming Azure CNI uses private IP range
Solution
Step 1: Identify the correct network plugin name for Azure CNI
The Azure CLI uses the exact stringazureto specify Azure CNI networking.Step 2: Check the command syntax
The command must include--network-plugin azureto enable Azure CNI networking.Final Answer:
az aks create --name myAKS --resource-group myRG --network-plugin azure -> Option AQuick Check:
Azure CNI plugin = azure [OK]
- Using 'azure-cni' instead of 'azure'
- Confusing kubenet with Azure CNI plugin name
- Typos in the network plugin parameter
Solution
Step 1: Understand pod communication in kubenet mode
In kubenet, pods get private IPs and use NAT on the node to communicate outside their node.Step 2: Analyze cross-node pod communication
Traffic between pods on different nodes goes through the node's NAT IP, requiring routing rules to allow this traffic.Final Answer:
The pod-to-pod traffic will be routed through the node's NAT IP and may require additional routing setup. -> Option DQuick Check:
Kubenet cross-node uses NAT routing [OK]
- Assuming direct pod IP communication in kubenet
- Thinking pods cannot communicate across nodes
- Believing pod traffic is blocked by default
Solution
Step 1: Check IP availability in Azure subnet
Azure CNI assigns pod IPs from the Azure subnet. If the subnet IP pool is exhausted, pods cannot get IPs.Step 2: Verify cluster network plugin and configuration
Since the cluster is deployed with Azure CNI, the plugin is installed. Host networking would not prevent IP assignment.Final Answer:
The Azure subnet does not have enough free IP addresses for pods. -> Option AQuick Check:
Subnet IP exhaustion blocks pod IP assignment [OK]
- Assuming plugin is missing when cluster uses Azure CNI
- Ignoring subnet IP exhaustion
- Confusing host networking with IP assignment
Solution
Step 1: Identify networking needs for direct pod-to-Azure resource communication
Direct communication requires pods to have IPs visible in the Azure virtual network.Step 2: Compare kubenet and Azure CNI capabilities
Kubenet uses NAT and private IPs, so pods are not directly reachable. Azure CNI assigns pod IPs from the Azure subnet, enabling direct communication.Final Answer:
Use Azure CNI because it assigns pod IPs from the Azure subnet enabling direct communication with Azure resources. -> Option CQuick Check:
Azure CNI = direct pod IPs in Azure subnet [OK]
- Choosing kubenet for direct pod IP communication
- Thinking kubenet allows direct pod IP visibility
- Disabling IP assignment in Azure CNI disables communication
