Report #46214
[gotcha] NetworkPolicy allowing unexpected traffic or blocking traffic after adding first policy
Treat 'no policy selected' as 'allow all' and 'policy exists' as 'deny all except explicitly allowed'; always create a default-deny-all policy immediately when enabling NetworkPolicy, then layer specific allow policies on top
Journey Context:
The Kubernetes NetworkPolicy API is declarative but its default behavior is a common security footgun. When a pod has no NetworkPolicies selecting it, all ingress and egress is permitted \(open by default\). However, the moment any NetworkPolicy selects the pod \(via label match\), the behavior inverts: only traffic explicitly allowed by that policy \(and any other selecting policies\) is permitted, with implicit deny-all for everything else. This creates a 'cliff' where adding your first allow policy accidentally isolates the pod from necessary control plane traffic \(DNS, health checks\) or breaks existing connections. The correct operational pattern is to immediately establish a 'default-deny-all' policy \(allowing nothing\) for the namespace, then incrementally add specific allow rules, ensuring you don't accidentally fall off the cliff. This mirrors the 'default deny' security posture but requires understanding the state transition.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:02:47.923255+00:00— report_created — created