pod dns is not resolved in k8s

4/23/2018

I have 2 services named A and B

I have pods a1,a2,a3 for Service A.

I have pods b1,b2,b3 for Service B.

Service A -> Type = ClusterIP

Service B -> Type= LoadBalancer

if I try to do nslookup from a1 -> b1 I am getting below error.

  >kubectl exec a1 -- nslookup b1

  nslookup: can't resolve '(null)': Name does not resolve
  nslookup: can't resolve 'cassandra-0': Name does not resolve
  command terminated with exit code 1

please help me to find the issue and why it's not reachable from other pods

updated with actual info::

                                    root-user> kubectl get  services --all-namespaces -o wide
        NAMESPACE     NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)                      AGE       SELECTOR
        default       kubernetes             ClusterIP      100.24.1.0       <none>                                                                    443/TCP                      26d       <none>
        default       registration-service   ClusterIP      None             <none>                                                                    8080/TCP                     18d       app=registration-service
        default       app-framework          ClusterIP      None             <none>                                                                    24366/TCP                    25d       app=app-framework
        default       stt                    LoadBalancer   100.56.9.26      a548cdb75447611e897960efe53682ba-1445165219.us-east-2.elb.amazonaws.com   8443:31327/TCP               3d        app=stt
        kube-system   kube-dns               ClusterIP      100.46.0.10      <none>                                                                    53/UDP,53/TCP                26d       k8s-app=kube-dns
        kube-system   kubernetes-dashboard   ClusterIP      100.96.205.42    <none>                                                                    443/TCP                      26d       k8s-app=kubernetes-dashboard
-- Slok
dns
kubernetes
kubernetes-pod
load-balancing

1 Answer

4/23/2018

It works as described in the docs. Here a simple example:

# in one terminal: 
$ kubectl run -i -t --rm there --restart=Never --image=quay.io/mhausenblas/jump:0.2 -- sh

# in another terminal
$ kubectl describe pod there | grep IP
IP:           172.17.0.7
$ kubectl run -i -t --rm here --restart=Never --image=quay.io/mhausenblas/jump:0.2 -- sh
~ $ nslookup 172-17-0-7.default.pod
nslookup: can't resolve '(null)': Name does not resolve

Name:      172-17-0-7.default.pod
Address 1: 172.17.0.7
-- Michael Hausenblas
Source: StackOverflow