0
0
Kubernetesdevops~10 mins

Container Network Interface (CNI) in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Container Network Interface (CNI)
Pod requests network
Kubelet calls CNI plugin
CNI plugin configures network
Assign IP & setup routes
Pod network ready
Pod communicates over network
Shows how Kubernetes uses CNI plugins to set up networking for pods step-by-step.
Execution Sample
Kubernetes
kubectl apply -f pod.yaml
# Pod starts
# Kubelet calls CNI plugin
# CNI assigns IP
# Pod network ready
This sequence shows how a pod's network is set up using CNI when the pod starts.
Process Table
StepActionComponentResultNotes
1Pod creation requestedUser/Kubernetes APIPod object createdPod spec includes network request
2Kubelet detects pod startKubeletCalls CNI pluginTriggers network setup
3CNI plugin invokedCNI pluginReads config and allocates IPAllocates IP from network pool
4Network interfaces configuredCNI pluginNetwork namespace setupRoutes and interfaces added
5Pod network readyKubeletPod can send/receive packetsPod joins cluster network
6Pod communicatesPodNetwork traffic flowsPod uses assigned IP
7Pod deletedUser/Kubernetes APIKubelet calls CNI DELNetwork resources cleaned up
8CNI cleans networkCNI pluginIP released and interfaces removedPrepares for next pod
9EndSystemPod network lifecycle completeNetwork resources freed
💡 Pod deleted and network cleaned up, ending the network lifecycle
Status Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
Pod IPNone10.244.1.510.244.1.510.244.1.5None
Network InterfacesNoneeth0 createdeth0 configuredeth0 activeRemoved
Routing TableEmptyRoutes addedRoutes activeRoutes activeRoutes removed
Key Moments - 3 Insights
Why does the pod have no IP before the CNI plugin runs?
Before step 3 in the execution_table, the pod network is not set up, so no IP is assigned yet.
What happens if the CNI plugin fails to assign an IP?
The pod network setup fails at step 3, so the pod cannot communicate and will not become ready.
Why is the network cleaned up after pod deletion?
At steps 7 and 8, the CNI plugin removes interfaces and releases IPs to avoid resource leaks for future pods.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what IP is assigned to the pod after step 3?
A10.244.1.5
BNone
C192.168.0.1
D127.0.0.1
💡 Hint
Check the 'Pod IP' variable in variable_tracker after step 3
At which step does the pod network become ready for communication?
AStep 4
BStep 5
CStep 2
DStep 7
💡 Hint
Look for 'Pod network ready' in the execution_table
If the pod is deleted, what happens to the network interfaces?
AThey remain active
BThey are duplicated
CThey are removed
DThey are renamed
💡 Hint
See steps 7 and 8 in execution_table and variable_tracker final state
Concept Snapshot
Container Network Interface (CNI) in Kubernetes:
- Kubelet calls CNI plugin to set up pod network
- CNI plugin assigns IP and configures interfaces
- Pod network ready after setup
- On pod deletion, CNI cleans network resources
- Enables pod communication inside cluster
Full Transcript
Container Network Interface (CNI) is how Kubernetes sets up networking for pods. When a pod starts, the kubelet calls the CNI plugin. The plugin assigns an IP address and configures network interfaces and routes inside the pod's network namespace. Once done, the pod can communicate over the cluster network. When the pod is deleted, the kubelet calls the CNI plugin to clean up network resources like IP addresses and interfaces. This process ensures pods have isolated, functional networking and resources are reused efficiently.