Skip to content
beginner Phase 4 · Networking

Kubernetes Networking Model

Understand the Kubernetes networking model and CNI-based pod networking.

1h
0 problems
Topic Progress 0%

The Three Rules

The Three Rules

Kubernetes defines a flat networking contract and leaves implementation to plugins:

  1. Every pod gets its own IP address; no NAT between pods.
  2. Any pod can reach any other pod on the same node without a proxy hop.
  3. Agents on a node can see all pods on that node without NAT.

The consequence is a cluster-wide flat IP space: pod A talks to pod B by IP regardless of node, and hostNetwork pods opt out by sharing the node's network namespace. Services then layer stable virtual IPs on top of pod IPs that come and go — the model separates identity (Service) from location (pod endpoints).

How the CNI Realizes It

How the CNI Realizes It

When kubelet starts a pod, it invokes the CNI plugin configured in /etc/cni/net.d. The plugin:

  1. Creates a veth pair — one end in the pod namespace, one on the host.
  2. Assigns the pod IP from a node-local allocator (often a /24 carved from a larger pod CIDR).
  3. Adds routes so the host can reach the pod, and programs cross-node traffic via VXLAN, BGP, or a cloud route table.
ip route show table all | grep -i tunl   # example: per-node pod routes
kubectl get pod web-abc -o jsonpath='{.status.podIP}'

kube-proxy then watches Services and programs iptables/IPVS rules that redirect the virtual Service IP to those pod IPs.

Pitfalls and Interview Angles

Pitfalls and Interview Angles

Pitfall 1 — overlapping pod CIDRs. If two nodes allocate the same pod IP, traffic blackholes intermittently. Allocate disjoint per-node blocks (the controller-manager --cluster-cidr with --allocate-node-cidrs=true does this for routed modes) or trust your CNI's IPAM.

Pitfall 2 — assuming ping proves the path. ICMP may be blocked while TCP works, or vice versa through policy. Test with the real port: kubectl run tmp --image=busybox --rm -it -- wget -qO- http://svc:8080/healthz.

Interview-ready: recite the three rules from memory, explain pod IP allocation and cross-node encapsulation for your CNI of choice, and separate pod-network problems (CNI, routes) from Service problems (endpoints, kube-proxy rules).

Quiz

1. What happens to pod IPs across nodes in the Kubernetes model?

Question 1 options

2. Which component programs Service traffic to pod endpoints?

Question 2 options

3. Where do most CNI plugins get pod IPs from?

Question 3 options

Flashcards

Question

The three networking rules

Answer

Unique pod IP, pod-to-pod without NAT, node agents see local pods without NAT.

Question

CNI plugin job

Answer

veth pair, pod IP assignment, routes/tunnels — invoked by kubelet from /etc/cni/net.d.

Question

flat IP space vs Services

Answer

Pod IPs are location; Services provide stable virtual IPs over changing endpoints.

Question

Test connectivity properly

Answer

Probe the real port and protocol (wget/nc), not just ICMP ping.

Revision Notes

Key Takeaways

  • 1. Kubernetes mandates the behavior, not the mechanism — CNI supplies the mechanism
  • 2. Overlapping pod CIDRs cause the classic blackhole failure
  • 3. Separate pod-network debugging from Service/kube-proxy debugging

Interview Tips

  • • Recite the three rules, then explain your CNI's encapsulation choice
  • • Walk a packet: pod → veth → host route/tunnel → peer host → pod

Cheat Sheet

Rules: unique pod IP, no NAT pod-to-pod, node agents see local pods. CNI = veth + IPAM + routes/tunnel; kube-proxy maps Service VIP to endpoints.

Continue Learning

Before You Start

  • No prerequisites listed.

Next Topics