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 →
- Without policies all pod-to-pod traffic is allowed
- Create a default-deny:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy spec: podSelector: {} policyTypes: [Ingress] - Then add allow policies by label
- Check the CNI supports policy (Calico, Cilium; the VPC CNI needs the network policy agent)
- Test with
kubectl execandcurlbetween 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.
More on Kubernetes Networking
Explain the Kubernetes networking model in one minute.BeginnerClusterIP, NodePort and LoadBalancer: when do you use each?BeginnerHow does a pod find another service by name?BeginnerService versus Ingress: what is the difference?BeginnerWhat does a CNI plugin do and which ones do you know?BeginnerHow do you reach a pod from your laptop for debugging without exposing it?Beginner