⚡ ~/naveed k8s
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Phase 2 — Cluster Administration Module 12 of 24 Free & Open Access

Networking Deep Dive (CNI, NetworkPolicy)

Complete production curriculum breakdown. Learn core architectural mechanics, study definitions in plain language, practice hands-on labs with the local minikube prod-sim cluster, and test active recall.

12 - Networking Deep Dive (CNI, NetworkPolicy)

Why this matters

Networking is the #1 area where "it works" turns into a multi-hour debugging session. This topic is what actually separates people who can operate a cluster from people who can only deploy YAML into one someone else built.

Read this first — Definitions & Explanations

CNI (Container Network Interface)

Plugin interface that sets up Pod networking: interfaces, IPs, routes. Examples: Calico, Cilium, Flannel.

Pod network

Every Pod gets an IP. Nodes must route Pod ↔ Pod traffic according to the CNI design (overlay or routing-based).

NetworkPolicy

API for allowing/denying traffic to/from Pods. Only enforced if your CNI supports NetworkPolicy. Without support, policies may be stored but not applied.

Default-open reality

Many clusters allow all Pod-to-Pod traffic until you write restrictive NetworkPolicies. Don’t assume isolation exists by default.

CoreDNS

Cluster DNS. Services get DNS names; Pods resolve them via CoreDNS. DNS breakage looks like “random app failures.”

Overlay vs underlay

Official docs (read for detail)

Key Concepts

YouTube search terms

Hands-on lab (on prod-sim)

# Check current CNI
kubectl get pods -n kube-system | grep -i -E 'calico|cilium|flannel|kindnet'
# minikube's default is usually a simple bridge CNI - check what NetworkPolicy support it has

# Default-deny all ingress in a namespace, then allow one specific path
kubectl create namespace netpol-test
kubectl -n netpol-test create deployment web --image=nginx
kubectl -n netpol-test expose deployment web --port=80
kubectl -n netpol-test run client --image=busybox --restart=Never -- sleep 3600

# baseline: client can reach web
kubectl -n netpol-test exec client -- wget -qO- --timeout=2 web

cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny
  namespace: netpol-test
spec:
  podSelector: {}
  policyTypes: ["Ingress"]
EOF
kubectl -n netpol-test exec client -- wget -qO- --timeout=2 web   # should now hang/fail

cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-client
  namespace: netpol-test
spec:
  podSelector:
    matchLabels:
      app: web
  policyTypes: ["Ingress"]
  ingress:
  - from:
    - podSelector:
        matchLabels:
          run: client
EOF
kubectl -n netpol-test exec client -- wget -qO- --timeout=2 web   # works again

# DNS troubleshooting drill
kubectl -n netpol-test exec client -- nslookup web.netpol-test.svc.cluster.local
kubectl -n kube-system logs -l k8s-app=kube-dns --tail=50

Note: if your CNI doesn't enforce NetworkPolicy, install Calico for this lab: minikube start -p prod-sim --cni=calico (recreate cluster with this flag).

Notes

(fill in your own words after watching + labbing)

📋 Self-Assessment Mastery Checklist (4 Competencies)
🧠 Practice Exam Questions (Module 12 MCQs)
⚡ Take Quiz & Save Progress in Tracker

Review these sample exam questions out loud, test your retrieval, and then unlock official scoring in the interactive tracker.

Question 1: CNI plugins are responsible for:
  • A. Pod network setup (interfaces/IPs/routes)
  • B. Scheduling Pods
  • C. Storing Secrets
  • D. Rendering Helm templates
✓ Correct Answer: A (Pod network setup (interfaces/IPs/routes))
Option A ('Pod network setup (interfaces/IPs/routes)') is the standard production architectural best practice.
Question 2: NetworkPolicy (with a supporting CNI) controls:
  • A. Which traffic Pods can send/receive
  • B. PVC size
  • C. API Priority and Fairness only
  • D. Image pull secrets
✓ Correct Answer: A (Which traffic Pods can send/receive)
Option A ('Which traffic Pods can send/receive') is the standard production architectural best practice.
Question 3: By default, without NetworkPolicies, Pods often can:
  • A. Talk freely within the cluster network (implementation-dependent but commonly open)
  • B. Never talk across namespaces
  • C. Only talk to etcd
  • D. Only use NodePort
✓ Correct Answer: A (Talk freely within the cluster network (implementation-dependent but commonly open))
Option A ('Talk freely within the cluster network (implementation-dependent but commonly open)') is the standard production architectural best practice.
Question 4: CoreDNS provides:
  • A. Cluster DNS resolution
  • B. Service load balancing L4 by itself
  • C. Volume snapshots
  • D. Admission webhooks
✓ Correct Answer: A (Cluster DNS resolution)
Option A ('Cluster DNS resolution') is the standard production architectural best practice.
Question 5: Overlay vs underlay networking refers to:
  • A. How Pod packets are encapsulated/routed on the node network
  • B. Helm chart types
  • C. RBAC models
  • D. StorageClasses
✓ Correct Answer: A (How Pod packets are encapsulated/routed on the node network)
Option A ('How Pod packets are encapsulated/routed on the node network') is the standard production architectural best practice.
← Previous Module (11) Installing & Upgrading Clusters (kubeadm) Next Module (13) → Troubleshooting & Debugging