Kubernetes Pod DNS Resolution
@mk_sta 's answer a bit easier to work with you can run this one liner to test your DNS:
kubectl run busybox --image=busybox --rm --attach --command -- sh -c "cat /etc/resolv.conf; nslookup $POD.$NAMESPACE.pod.cluster.local"
Example output:
If you don't see a command prompt, try pressing enter.
Server: 100.64.0.10
Address: 100.64.0.10:53
*** Can't find $POD.$NAMESPACE.pod.cluster.local: No answer
deployment.apps "busybox" deleted
Bonus is that it deletes the deployment/pods after running.
For me the problem was that my pods are in a statefulset and therefore Pod DNS resolution is a bit different. You have to use (for example):
web-{0..N-1}.nginx.default.svc.cluster.local
pod-N.$GOVERNING_STATEFULSET.$NAMESPACE.svc.cluster.local
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
That's one thing that can go wrong. You may want to provide more info about your particular case.