Interview Prep/Networking/Kubernetes & Service Networking in Production

How do you design default-deny NetworkPolicies without breaking DNS?

IntermediateProductionKubernetes & Service Networking in Production
Answer

Apply a default-deny for ingress and egress in each namespace, then allow explicitly: DNS to kube-dns on UDP and TCP 53, traffic from ingress controller namespace, app-to-app flows, and egress to required external CIDRs.

egress:
- to:
  - namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: kube-system}}
    podSelector: {matchLabels: {k8s-app: kube-dns}}
  ports: [{protocol: UDP, port: 53}, {protocol: TCP, port: 53}]

Roll out in audit mode first (Cilium policy audit, Calico staged policies).

All Networking questions Roadmap: Networking for DevOps

More on Kubernetes & Service Networking in Production