Network Policies Best Practices
This is a practitioner's checklist for adopting NetworkPolicy without outages. Start with namespace isolation, then iterate down to pod-level allow-lists.
Search across all documentation pages
This is a practitioner's checklist for adopting NetworkPolicy without outages. Start with namespace isolation, then iterate down to pod-level allow-lists.
Work top to bottom. The groups are ordered as a rollout path: prove enforcement, establish a default-deny floor, restore essentials, then tighten and operationalize.
Apply changes through GitOps so every policy is reviewed and reversible. Treat each namespace lacking a default-deny as an open finding.
kubectl get netpol proves an object exists, not that it drops traffic. Verify with a probe pod that allowed paths pass and others hang.netshoot pod per environment so you can curl and dig from inside the mesh of policies at any time.policyTypes.ipBlock.from. Selectors inside one list element are ANDed; separate list items are ORed. Re-read indentation when a rule looks too broad.ports list to each allow so a rule opens only the protocol and port the dependency needs.k8s-app: kube-dns label.toFQDNs for per-domain egress; never leave egress open to the internet.kubectl apply --dry-run=server catches schema errors early.Every namespace holding real data has a default-deny for ingress and egress, plus a DNS allow and only the specific allow-rules its workloads need.
Enforcement is verified by probe, policies live in Git, and flow logs let you explain any drop. New namespaces inherit the deny automatically.
Where do I start on an existing cluster? Pick one namespace, add a default-deny with DNS and probe allows, verify, then repeat outward.
Namespace isolation or pod-level first? Begin with namespace-level default-deny for a quick safety floor, then iterate to pod-level allow-lists.
How do I avoid breaking DNS? Always ship a DNS egress allow (UDP and TCP 53) in the same change as any egress deny.
How do I know a policy is enforced? Test with a probe pod; a genuine drop shows as a hang. Confirm your CNI enforces policy at all.
Should policies live in Git? Yes. GitOps makes every change reviewed, auditable, and reversible, and prevents silent re-opening.
Do I still need this in a single-tenant cluster? Yes, to contain blast radius if any one workload is compromised.
Stack versions: This page was written for Kubernetes 1.36.2, Docker Engine 29.6.1 (BuildKit default), containerd (CRI runtime on nodes), Helm 3, Compose v2, Argo CD (latest - verify at build), and Gateway API (GA - verify controller support at build).
Reviewed by Chris St. John·Last updated Jul 19, 2026