BM: Baca dalam Bahasa Melayu
World K6: Guards
NetworkPolicies recap
You will learn: to fence a database so only the pods that need it can reach it.
Checked with Kubernetes 1.37 on 31 Oct 2026
The problem
The gates stop strangers at the door. But inside, any tray can talk to the database. A thief gets into the web pod. Then what?
Pick one answer.
Watch
Recap from World K3: a NetworkPolicy is a fence between stalls. This one lets the entrance in. Break it: forget the entrance. Then send.
Break one hop so the user gets: a timeout.
- BrowserGET /api/menu on port 80
- Gateway (entrance)entrance listens on :80
- HTTPRoute (signboard)/api → api:80
- Service (order number)api: port 80 → 3000
- EndpointSlice (ready trays)1 ready of 1
- Pod (tray)api-7d4f9-x2kq4 listens on :3000
Try it
This fence will not apply. Fix the line the API server does not know.
Fix the manifest, then press Apply.
Try it
Fence the database for real. Apply the deny-all fence. Then open a gate for api only.
kind-dev namespace defaultdb1/1 ready
dev-control-planeOpenManagerNo trays here.
dev-workerOpen- db·vq5t2
- stranger
dev-worker2Open- api
Hint
Two files, in order:deny.yaml, then allow-api.yaml.Predict
Your cluster’s network plugin ignores NetworkPolicies. You apply deny-all. What happens?
Pick one answer.
Check
Good fence habit, or risky? Swipe each one.
Swipe right for good, left for needs work. Or use the buttons.
Start each zone with deny-all, then open small gates
You did it!
You can now fence a database with NetworkPolicies.
Go deeper (optional)
policyTypes: [Egress] fences what goes out. namespaceSelector lets a whole zone through. Plugins like Cilium and Calico enforce policies. Check your plugin’s docs before you trust a fence.
Real mission
kubectl apply -n fence-test -f deny.yaml
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Pintu-pintu halang orang asing di luar. Tapi di dalam, mana-mana dulang boleh bercakap dengan pangkalan data. Pencuri masuk ke pod web. Lepas tu?
Ulang kaji dari Dunia K3: NetworkPolicy ialah pagar antara gerai. Pagar ini benarkan pintu masuk. Rosakkannya: lupakan pintu masuk. Kemudian hantar.
Pagar ini tak boleh di-apply. Baiki baris yang API server tak kenal.
Pagar pangkalan data betul-betul. Apply pagar deny-all. Kemudian buka pintu untuk api sahaja.
deny.yaml, kemudian allow-api.yaml.Plugin rangkaian kluster anda abaikan NetworkPolicy. Anda apply deny-all. Apa jadi?
Tabiat pagar yang baik, atau berisiko? Leret setiap satu.
Kini anda boleh pagar pangkalan data dengan NetworkPolicy.
You finished this before. Practice is always welcome!
Official docs: Network Policies · Declare a network policy
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?