Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

Inside a Pod, `nslookup orders` returns `;; connection timed out; no servers could be reached`.

BeginnerTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → Pods cannot reach CoreDNS: CoreDNS Pods down, the kube-dns Service has no endpoints, a NetworkPolicy blocks UDP/TCP 53, or security groups block traffic between nodes.

Diagnose →

kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl get endpointslices -n kube-system -l kubernetes.io/service-name=kube-dns
kubectl exec web-x -- cat /etc/resolv.conf
kubectl run dnstest --rm -it --image=busybox:1.36 --restart=Never -- nslookup kubernetes.default

Fix → Restore CoreDNS (scale up, fix crash), add a NetworkPolicy egress rule for DNS, or open node-to-node UDP/TCP 53.

Prevent → At least 2 CoreDNS replicas with anti-affinity and a PDB, plus a DNS probe in synthetic monitoring.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy