Interview Prep/Networking/Kubernetes Networking

By default, can any pod talk to any other pod, and how do you change that?

BeginnerScenarioKubernetes Networking
Answer

Situation read → Kubernetes is open by default; isolation requires NetworkPolicy and a CNI that enforces it.

What I'd do →

  1. Without policies all pod-to-pod traffic is allowed
  2. Create a default-deny: apiVersion: networking.k8s.io/v1 kind: NetworkPolicy spec: podSelector: {} policyTypes: [Ingress]
  3. Then add allow policies by label
  4. Check the CNI supports policy (Calico, Cilium; the VPC CNI needs the network policy agent)
  5. Test with kubectl exec and curl between pods

Why → A NetworkPolicy object does nothing unless the CNI enforces it.

Interview tip → Say you remember to allow DNS egress when you add default-deny egress.

All Networking questions Roadmap: Networking for DevOps

More on Kubernetes Networking