by ecliptik · 3y ago · 0 comments
For DNS, my favorite interview question goes like this,
How would you verify DNS is resolving from within a pod on Kubernetes?
After listening to the answer, add some constraints:
1. Common networking utilities like ping, nslookup, dig, etc are not available
2. Container user is unpriviledged
3. su/sudo do not work
This can lead to some elaborate k8s troubleshooting or the simple, and correct, answer of getent hosts.
I don't know Kubernetes, so it's very possible that Kubernetes enforces that name resolution is always DNS and only DNS (a "hosts: dns" line in /etc/nsswitch.conf, without any additional stuff like files which would mean resolution via /etc/hosts), in which case getent is indeed correct, but in the general case, there is no system-intrinsic tool that tests DNS only, and you have to use something like dig.