Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Different namespaces, same cluster
Your dev app can talk to your prod database. Here, a Pod, which is a running instance of your app, sits in the dev namespace, a named group for organizing Kubernetes objects. The database Pod sits in prod. Yet the dev app connects through the cluster network, and it's allowed.
Namespaces label things; they don't wall them off
Here's why. A namespace is just a label that groups Kubernetes objects, like a folder on a desk. It organizes names and access to objects. It doesn't build a wall around the network. By default, every Pod sits in one open room, so dev and prod Pods can talk freely.
Part 3
On the left, there's no policy. The dev app Pod sends traffic straight to the prod database, and nothing stops it. On the right, we add a NetworkPolicy, a rule that limits which Pods can talk to each other. Now the shield in front of prod stops the arrow from dev.
Fix: allow only what prod needs
The fix is a NetworkPolicy in prod, attached to the database. It lets the prod app Pod through, so that traffic is allowed. The dev app Pod's request reaches the same policy, and it's denied. You're allowing only what prod needs. One caveat: this works only if the cluster's network plugin enforces NetworkPolicy.
Separate folders aren't separate rooms.
Separate folders aren't separate rooms. Whenever namespaces need real isolation, add NetworkPolicies, and make sure your network plugin actually enforces them.

