Menu

Kubernetes Cookbook Part 11: Network Policies, the Firewall You Forgot to Turn On
📰

Kubernetes Cookbook Part 11: Network Policies, the Firewall You Forgot to Turn On

DEV Community: kubernetes·FlatlinerAtheist | CLI-NERDS·about 14 hours ago
#IFUvU4n8
#devtokubernetes#devto#dev#pods#ingress
Reading 0:00
15s threshold

Here's a scenario that should make you uncomfortable: in a default Kubernetes cluster, every pod can talk to every other pod. Your public-facing web app can reach the database directly. A random test container can poke the kubelet. If one pod gets compromised — and one will, eventually — the attacker lands in a network with zero internal walls.

Kubernetes has a built-in answer, and almost nobody turns it on: NetworkPolicy . It's a firewall for your pods, declared the same way you declare everything else. This is Part 11 of the Kubernetes Cookbook — and it's the one I wish I'd read before my first cluster grew past three apps.

The mental model: allow-all by default

The most important thing to understand: NetworkPolicy is opt-in, and doing nothing means allow everything. Applying zero network policies is not "no firewall" — it's "firewall with a permanent allow-all rule."

The moment you apply any NetworkPolicy to a pod, that pod flips from allow-everything to allow-only-what-the-policy-says.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.