Report #54388
[gotcha] First Kubernetes NetworkPolicy causes sudden traffic drop despite no explicit deny rules
When creating the first NetworkPolicy for a pod, explicitly define ingress rules allowing required traffic \(e.g., \`\{\}\` for all sources or specific namespace/pod selectors\), recognizing that the first policy switches the pod from 'allow all' \(no policies\) to 'deny all except explicit allows' \(policy exists\).
Journey Context:
Kubernetes NetworkPolicy implements a whitelist model with an implicit state transition. With zero NetworkPolicies selecting a pod, the pod is in an 'open' state—all ingress and egress is permitted. The moment any NetworkPolicy selects the pod \(via podSelector\), Kubernetes applies a default-deny stance for that traffic direction \(ingress or egress as specified in policyTypes\), only permitting what is explicitly listed in the policy rules. This is counter-intuitive to firewall administration where absence of rules equals deny. Common mistakes include deploying a 'logging only' policy that selects pods but has empty rules, expecting it to monitor traffic while allowing it, or assuming that specifying only \`policyTypes: \["Ingress"\]\` without rules means 'allow all ingress'. Alternatives considered include using Cilium's Cluster-wide Network Policies or Calico GlobalNetworkPolicies which can enforce default-deny across the cluster without per-pod policies, but these require CNI support. The correct approach is to treat the first NetworkPolicy as a critical infrastructure change requiring explicit allow rules for all necessary communication paths, validating with \`kubectl exec\` and network probes before production deployment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:47:06.299594+00:00— report_created — created