When you deploy workloads to Kubernetes, you expect isolation. You expect control over how pods talk to each other. Without it, you’re exposed. A tiny misconfiguration can turn into an open corridor into your cluster. Kubernetes Network Policies shut those corridors. They decide who speaks to whom and on what terms.
Network Policies work at the IP and port level for pods. They use labels and selectors to define rules. They can allow or block incoming traffic (ingress), outgoing traffic (egress), or both. Without a policy, every pod can connect to every other pod in the namespace. The default is wide open.
A simple example: You label your app pods, then create a NetworkPolicy that only allows ingress from certain front-end pods. Those IP flows are enforced at the node by the network plugin — whether it’s Calico, Cilium, or another CNI. Your choice of CNI decides which features are available. Some support advanced capabilities like DNS-based rules or CIDR exceptions.
Here’s the trap: a NetworkPolicy with no matching selectors won’t block anything. And a policy that allows ingress from one group doesn’t stop egress to everything else unless you define it. Strong isolation usually needs both ingress and egress defined explicitly. Think of it as closing every door you are not using.