BM: Baca dalam Bahasa Melayu
World K3: Counters & Doors
NetworkPolicies and CNI plugins
You will learn: to lock pod doors by default, and let in only the pods you choose.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
kind-dev namespace defaultA stranger tray walks straight into the shop kitchen. By default, every door in the cluster is open.
Watch
A NetworkPolicy: A guest list on a pod's door: which pods may come in, chosen by label. is a guest list on a pod’s door. Nobody on the list? The door stays shut. Turn on the lock, then send an order.
Break one hop so the user gets: a timeout.
- BrowserGET / on port 80
- Gateway (entrance)entrance listens on :80
- HTTPRoute (signboard)/ → shop:80
- Service (order number)shop: port 80 → 80
- EndpointSlice (ready trays)2 ready of 2
- Pod (tray)shop-94c9756fd-8tghh listens on :80
Hint
The lock drops packets. Nobody says no, so the customer just waits.Predict
You apply this policy. Can the client still reach the shop?
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
spec:
podSelector: {}
policyTypes:
- IngressPick one answer.
Try it
Every door is locked now. Let only the client back in with allow-client.yaml.
kind-dev namespace defaultshop3/3 ready
dev-control-planeOpenManagerNo trays here.
dev-workerOpen- shop·6n92s
- shop·pfz6p
- stranger
dev-worker2Open- client
- shop·c24gr
Its guest list:
ingress:
- from:
- podSelector:
matchLabels:
app: client
ports:
- port: 80Check
This lock won’t apply. Read kubectl’s words, then fix it.
Fix the manifest, then press Apply.
Plain words: Kubernetes knows Ingress and Egress, with capitals only.
Watch
A policy is only words. The CNI plugin: The food court's walkways: the network plugin that gives pods IPs and enforces NetworkPolicies. plugin, the food court’s walkways, makes them real. Which plugins do that?
Drag a card into a box. Or tap the card, then tap the box.
Check
Judge each habit.
Swipe right for good, left for needs work. Or use the buttons.
Start a namespace with deny-all, then allow by label.
You did it!
You can now lock pod doors, and let in only the right pods.
Go deeper (optional)
Where the story breaks: a Service is not a real counter. Nobody stands there; each stall just rewrites addresses. A locked door makes no sound: dropped packets vanish, so you see a timeout. Policies add up: any matching allow rule opens the door. Egress rules can block DNS too.
Real rep (optional), on kind 0.24 or newer:
Real mission
kubectl get networkpolicy
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Dulang orang asing masuk terus ke dapur kedai. Secara lalai, setiap pintu dalam kluster terbuka.
NetworkPolicy ialah senarai tetamu di pintu pod. Tiada dalam senarai? Pintu kekal tertutup. Hidupkan kunci, kemudian hantar pesanan.
Anda apply policy ini. Bolehkah client masih sampai ke kedai?
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
spec:
podSelector: {}
policyTypes:
- Ingress
Setiap pintu kini berkunci. Benarkan client sahaja masuk semula dengan allow-client.yaml.
Senarai tetamunya:
ingress:
- from:
- podSelector:
matchLabels:
app: client
ports:
- port: 80
Kunci ini tak boleh apply. Baca kata-kata kubectl, kemudian baiki.
Maksudnya: Kubernetes kenal Ingress dan Egress, dengan huruf besar sahaja.
Policy hanya kata-kata. Plugin CNI, laluan pejalan kaki medan selera, yang jadikannya nyata. Plugin mana yang buat begitu?
Nilai setiap tabiat.
Kini anda boleh kunci pintu pod, dan benarkan hanya pod yang betul.
You finished this before. Practice is always welcome!
Official docs: Kubernetes: Network Policies · Kubernetes: network plugins
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?