How to verify cluster network policy configuration/support
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Kubernetes NetworkPolicy resources are only enforced if the cluster's CNI (Container Network Interface) plugin supports them. Deploying a NetworkPolicy on a cluster without a compatible CNI plugin (like the default kubenet) silently does nothing — the policy exists as a Kubernetes object but has no effect on traffic. Verifying that your cluster actually enforces network policies requires checking the CNI plugin, deploying a test policy, and confirming that traffic is blocked as expected.
Check Your CNI Plugin
Not all CNI plugins support NetworkPolicy. You must verify which CNI is running in your cluster.
| CNI Plugin | NetworkPolicy Support |
| Calico | Full (ingress + egress) |
| Cilium | Full (ingress + egress + L7) |
| Weave Net | Full (ingress + egress) |
| Flannel | None |
| kubenet | None |
| Canal (Calico + Flannel) | Full |
Deploy a Test NetworkPolicy
Create a deny-all ingress policy and verify it blocks traffic.
Allow Specific Traffic
After confirming the deny-all policy works, add a policy that allows specific traffic.
Using CNI-Specific Tools to Verify
Clean Up Test Resources
Common Pitfalls
- Assuming NetworkPolicy works without checking the CNI: The Kubernetes API accepts NetworkPolicy objects regardless of CNI support. On Flannel or kubenet, policies are created successfully but have zero effect on traffic. Always verify enforcement with a deny-all test before relying on policies.
- Forgetting
policyTypesfield: Without specifyingpolicyTypes, Kubernetes infers it from the rules present. An empty policy with nopolicyTypesand no rules does nothing. Always explicitly setpolicyTypes: ["Ingress"]orpolicyTypes: ["Ingress", "Egress"]. - Not testing egress policies separately: Even if ingress policies work, egress enforcement may behave differently. Some CNI configurations enforce ingress but not egress by default. Test both directions independently.
- Namespace-scoped confusion: NetworkPolicy is namespace-scoped. A policy in namespace A does not affect pods in namespace B. For cross-namespace restrictions, you need policies in both namespaces or use a CNI-specific cluster-wide policy (Calico GlobalNetworkPolicy, Cilium CiliumClusterwideNetworkPolicy).
- DNS resolution breaking after deny-all egress: A deny-all egress policy blocks DNS (port 53) traffic to CoreDNS. Pods cannot resolve service names and appear to have no network connectivity. Always allow egress to DNS when applying egress policies: allow UDP port 53 to the
kube-systemnamespace.
Summary
- Verify your CNI plugin supports NetworkPolicy — Calico, Cilium, and Weave do; Flannel and kubenet do not
- Deploy a deny-all policy and test with
wget/curlfrom a client pod to confirm enforcement - Always explicitly set
policyTypesin your NetworkPolicy spec - Use CNI-specific tools (calicoctl, Cilium Hubble) for detailed policy debugging
- Allow DNS egress (UDP 53) when applying deny-all egress policies
- Clean up test resources after verification
Related reading
- How to verify Kubernetes service account token JWT
- How to view logs of failed jobs with kubectl?
- How to view the permissions/roles associated with a specific service account in k8s?
- How to write a chart for imagePullSecret from gcr
- How to view the SQL queries issued by JPA?
- How to wait for google geocoder.geocode?
- Http Basic Authentication in Java using HttpClient?
- HttpClient and using proxy - constantly getting 407

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.