2
votes

I have successfully created a Kubernetes POD/Service using MiniKube on windows. But I would now like to ensure that DNS is working correctly.

The DNS service is shown as running

.\kubectl get pod -n kube-system

Which shows me the kube-dns pod is running

enter image description here

I also have the DNS add on shown as running

enter image description here

So I then want to verify that DNS is working, Ideally I want to test that PODs that have a service on top of them can lookup the service by DNS name.

But I started simple like this, where I get my running POD

enter image description here

So now that I have my POD name, I want to try do simple DNS lookup in it using the following commmand

.\kubectl exec simple-sswebapi-pod-v1-f7f8764b9-xs822 -- nslookup google.com

Where I am using the kubectl exec to try and run this nslookup in the POD that was found (running I should point out above).

But I get this error

enter image description here

Why would it not be able to find nslookup inside POD. All the key things seem to be ok

  • Kube-DNS pod is running (as shown above)
  • DNS AddOn is installed and running (as shown above)

What am I missing, is there something else I need to enable for DNS lookups to work inside my PODs?

2
You do not have nslookup tool inside the pod (your image doesn't have it). Execute a shell inside the pod and install nslookup and then try again. - tselvan
does that mean the shell command needs to be part of my initial docker image. Or can I do that now? If so any chance of an example. I am new to this. Guess this is why most examples I have seen of DNS lookup use busybox which comes with nslookup - sacha barber
Think what I will do is create a new service/POD that uses busy box just to check the DNS lookup stuff. Thanks again for your answer. You should promote your comment here to full answer, then I can vote you up - sacha barber
@tselvan I added another part to this question, any ideas on this new query? - sacha barber

2 Answers

1
votes

To do it like this your container needs to include the command you want to use inside of the built image.

Sidenote: kubectl debug is coming to kube in near future https://github.com/kubernetes/kubernetes/issues/45922 which will help solve things like that by enabling you to attach a custom container to existing pod and debug in it

1
votes

So more on this I installed busybox into a POD to allow me to use nslookup and this enabled me to do this

enter image description here

So this looks cool, but should I not be able to ping that service either by its IP address or by its DNS name which seems to be resolving just fine as shown above.

If I ping google.com inside busybox command prompt all is ok, but when I do a ping for either this IP address of this service of the DNS names, it never gets anywhere.

DNS lookup is clearly working. What am I missing?