Implement a NetworkPolicy default-deny posture and selectively open traffic

domain: kubernetes.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Apply a default-deny-all NetworkPolicy with an empty `podSelector: {}` and no `ingress` or `egress` rules to block all traffic in the namespace
  2. Create separate NetworkPolicy manifests to explicitly allow required ingress (e.g., from the ingress controller) and egress (e.g., to DNS on port 53)
  3. Use `namespaceSelector` combined with `podSelector` for cross-namespace allow rules
  4. Apply policies incrementally in a non-production namespace first to discover missing allow rules before enabling in production
  5. Verify with a debug pod running `curl` or `nc` to confirm allowed and blocked paths behave as expected

Known gotchas

Related routes

Configure Kubernetes NetworkPolicy to implement a default-deny posture and selectively allow ingress from a specific service
kubernetes.io · 6 steps · unrated
Configure a Kyverno generate policy to automatically create a default NetworkPolicy and ConfigMap when a new namespace is created
security/compliance · 5 steps · unrated
Write a Cilium L3/L4 NetworkPolicy to restrict pod-to-pod traffic
docs.cilium.io · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans