nslookup in busybox 1.29 does not work in kubernetes

Recently I was trying to use nslookup in pod initContainers in order to make sure that some services are available during pod startup. However, it didn’t work when I was using nslookup from busybox:1.29. After several tries, the DNS lookup still failed. I was really frustrated, because I remembered that it worked well when I tried the nslookup command for Service DNS.

# kubectl exec busybox-deploy-54b48d96f-rstwx nslookup redis-service

** server can’t find redis-service: NXDOMAIN

** server can’t find redis-service: NXDOMAIN

After searching the issue in google, I found that this does not involve my kubernetes cluster and the command usage. This is an nslookup bug in busybox 1.29 when it is used in kubernetes. The bug details can be found in the below two tickets:

To work around this issue, busybox 1.28 can be used. I tried that version and the nslookup command works well in kubernetes

# kubectl exec busybox-deploy-5c4ff5b4f8-n45hn nslookup redis-service
Address 1: kube-dns.kube-system.svc.cluster.local

Name: redis-service
Address 1: redis-service.default.svc.cluster.local