Kubernetes (GKE) internal lookups cannot be resolved

12/27/2018

I am having an issue with Kubernetes on GKE. I am unable to resolve services by name. I got an drone-server service running which is connected to a single pod. The ingress connected to the service is successfully connecting but when trying to do for example a nslookup from a busybox pod is it unable to resolve the hostname.

Services:

$ k get services -n drone
NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
drone-server   ClusterIP   10.39.242.23    <none>        80/TCP    2d
drone-vault    ClusterIP   10.39.248.166   <none>        80/TCP    40m

Busybox nslookup:

$ kubectl exec -ti busybox -- nslookup drone-server
Server:    10.39.240.10
Address 1: 10.39.240.10 kube-dns.kube-system.svc.cluster.local

nslookup: can't resolve 'drone-server'

When i try to lookup kubernetes.default am I getting a local address back:

$ kubectl exec -ti busybox -- nslookup kubernetes.default
Server:    10.39.240.10
Address 1: 10.39.240.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes.default
Address 1: 10.39.240.1 kubernetes.default.svc.cluster.local

Resolv config:

/etc/resolv.conf seems to be configured correctly (the nameserver is matching the kube-dns service cluster ip).

$ kubectl exec -ti busybox -- cat /etc/resolv.conf
nameserver 10.39.240.10
search default.svc.cluster.local svc.cluster.local cluster.local europe-west3-a.c.cluster-a8e6d9e252b63e03.internal c.cluster-a8e6d9e252b63e03.internal google.internal
options ndots:5
-- Jeroen Rinzema
kubernetes
networking

1 Answer

12/27/2018

Your drone-server service is in the drone namespace and you're trying to nslookup from default namespace. You need to provide the namespace also in command as follows:

kubectl exec -ti busybox -- nslookup drone-server.drone

This is because your busybox in the default namespace and it tries to look drone-server in same namespace.

-- Prafull Ladha
Source: StackOverflow