Report #15338
[gotcha] Kubernetes NetworkPolicy not blocking traffic despite deny rules being defined
Apply a 'default-deny-all' NetworkPolicy to every namespace immediately; NetworkPolicies only affect pods selected by their podSelector, and pods with no matching policies are non-isolated and accept all traffic by default
Journey Context:
Kubernetes NetworkPolicy operates as a whitelist \(default-deny\) for selected pods, but the critical subtlety is the 'isolation' concept. A pod is isolated only if at least one NetworkPolicy selects it via its podSelector \(or namespaceSelector combined with podSelector\). If zero policies select a pod, it is 'non-isolated' and accepts all ingress and egress traffic regardless of what policies exist elsewhere in the cluster. This is the opposite of AWS Security Groups or firewall rulesets where explicit rules apply. Developers often create a 'deny-all' policy but use a podSelector that doesn't match their app labels, or they assume that creating any policy in the namespace protects all pods. The safe operational pattern is: \(1\) Upon namespace creation, immediately apply a default-deny policy with empty podSelector \{\} matching all pods, and \(2\) explicitly allow required traffic with specific policies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:48:58.364663+00:00— report_created — created