Kubernetes How to confirm DNS is working

2019-06-02 04:21发布

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条回答
Emotional °昔
2楼-- · 2019-06-02 05:05

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?

查看更多
趁早两清
3楼-- · 2019-06-02 05:26

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

查看更多
登录 后发表回答