NetworkPolicy Does Not Block Traffic When Expected¶
Symptom¶
Traffic continues to flow even though the team expected a NetworkPolicy or Cilium policy to deny it.
Possible Causes¶
- The cluster is using a different policy engine than the author assumed.
- The policy does not select the intended pods.
- No namespace default-deny baseline exists, so traffic still falls through to default allow.
- The test path is not the path the policy actually governs.
- A migration is incomplete and old assumptions about enforcement timing still apply.
Diagnosis Steps¶
flowchart TD
A[Traffic still allowed] --> B[Confirm cluster network policy engine]
B --> C[Inspect policy selectors and targeted pods]
C --> D{Is there a default-deny baseline?}
D -->|No| E[Traffic falls through to default allow]
D -->|Yes| F[Check engine-specific behavior and migration state]
E --> G[Add or fix baseline then retest]
F --> G -
Confirm the cluster dataplane and network-policy engine.
az aks show \ --resource-group "$RG" \ --name "$CLUSTER_NAME" \ --query "networkProfile.{dataplane:networkDataplane,policy:networkPolicy,plugin:networkPlugin,mode:networkPluginMode}" \ --output yamlCommand Purpose az aks showShow the dataplane, policy, plugin, and mode. --resource-groupResource group that contains the AKS cluster. --nameName of the AKS cluster. --querySelects dataplane, policy, plugin, and mode. --outputOutput format for the result. -
Inspect the policy and verify that the selected pods are the ones you intended.
-
Check whether a namespace default-deny exists. If not, Kubernetes default behavior remains allow unless a matching policy says otherwise.
-
If the cluster recently moved to Cilium, confirm the migration finished and all nodes were reimaged before declaring the policy nonfunctional.
Resolution¶
- Correct the engine assumption first.
- Add namespace default-deny baselines where the security model depends on deny-by-default.
- Fix selectors so the policy actually targets the pods under test.
- For migrations, wait until the Cilium rollout is complete before validating final enforcement.
Prevention¶
- Record the cluster’s current dataplane and policy engine in every troubleshooting ticket.
- Standardize policy tests so they verify both “should allow” and “should deny” paths.
- Treat policy migration validation as a staged rollout, not a single command outcome.
See Also¶
- Best Practices: Networking
- Azure CNI Powered by Cilium
- NetworkPolicy Denies Legitimate Traffic
- Cilium Dataplane Migration Issues