<p>I have created a service(grpc-service) on my Kubernetes cluster(ubuntu 16.04) and cannot find it's dns Hostname </p>

<p>Also as a side node , my pod does not show up on nslookup (it works with busybox)</p>

<pre><code> kubectl exec -ti server-pod -- nslookup kubernetes.default
OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"nslookup\": executable file not found in $PATH": unknown
</code></pre>

<p>expecting somthing similar to:</p>

<pre><code>grpc-service.&lt;namespace&gt;.svc.&lt;cluster-domain&gt; which is usually
grpc-service.default.svc.cluster.local
</code></pre>

<p>but cannot find it ,neither can ping/curl it
(curl -I grpc-service)</p>

Tanmay Shrivastava
<p>Take below as an example. Make sure you use correct labels/selectors.
And use busybox version &lt;= <a href="https://github.com/kubernetes/kubernetes/issues/66924#issuecomment-411804435" rel="nofollow noreferrer">busybox:1.28.4</a> for tests. With newer version dns doesnt work correctly.</p>

<hr>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: busybox-pod
  labels:
    app: busybox
spec:
  containers:
  - image: busybox:1.28.4
    command:
      - sleep
      - "3600"
    imagePullPolicy: IfNotPresent
    name: busybox
  restartPolicy: Always
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
spec:
  hostNetwork: true
  containers:
  - name: client-pod
    image: nginx        
---
apiVersion: v1
kind: Service
metadata:
  name: server
  labels:
    app: nginx
spec:
  clusterIP: None
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  selector:
    app: nginx
---
</code></pre>

<p>Checking:</p>

<pre><code>kubectl get all -o wide
NAME              READY   STATUS    RESTARTS   AGE    IP            NODE                                                NOMINATED NODE   READINESS GATES
pod/busybox-pod   1/1     Running   0          5m6s   10.44.2.6     gke-standard-cluster-1-default-pool-00736803-xn08   &lt;none&gt;           &lt;none&gt;
pod/nginx-pod     1/1     Running   0          5m6s   10.164.0.16   gke-standard-cluster-1-default-pool-00736803-xn08   &lt;none&gt;           &lt;none&gt;


NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE    SELECTOR
service/kubernetes   ClusterIP   10.110.0.1   &lt;none&gt;        443/TCP   71m    &lt;none&gt;
service/server       ClusterIP   None         &lt;none&gt;        80/TCP    5m7s   app=nginx



kubectl describe service server
Name:              server
Namespace:         default
Labels:            app=nginx
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"nginx"},"name":"server","namespace":"default"},"spec":{"...
Selector:          app=nginx
Type:              ClusterIP
IP:                None
Port:              &lt;unset&gt;  80/TCP
TargetPort:        80/TCP
Endpoints:         10.164.0.16:80
Session Affinity:  None
Events:            &lt;none&gt;



kubectl -n default exec -ti busybox-pod -- nslookup kubernetes.default
Server:    10.110.0.10
Address 1: 10.110.0.10 kube-dns.kube-system.svc.cluster.local

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


kubectl -n default exec -ti busybox-pod -- ping server
PING server (10.164.0.16): 56 data bytes
64 bytes from 10.164.0.16: seq=0 ttl=64 time=0.089 ms
64 bytes from 10.164.0.16: seq=1 ttl=64 time=0.129 ms
64 bytes from 10.164.0.16: seq=2 ttl=64 time=0.156 ms
64 bytes from 10.164.0.16: seq=3 ttl=64 time=0.124 ms


kubectl -n default exec -ti busybox-pod -- cat /etc/resolv.conf
nameserver 10.110.0.10
search default.svc.cluster.local svc.cluster.local cluster.local 
options ndots:5
</code></pre>
