title: Zookeeper and headless service in kubernetes
body: <p>In kubernetes I have deployed a statefulset called zookeeper:</p>
  
  <pre><code>apiVersion: apps/v1beta1
  kind: StatefulSet
  metadata:
    name: zookeeper
  spec:
    serviceName: zookeeper-svc
    replicas: 1
    template:
      metadata:
        labels:
          app: zookeeper
  </code></pre>
  
  <p>and a headless service:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: zookeeper-svc
    labels:
      app: zookeeper    
  spec:
    clusterIP: None
    ports:
    - port: 2888
      name: server
    - port: 3888
      name: leader-election
  </code></pre>
  
  <p>Entering inside my zookeeper-0 pod I can see its IP:</p>
  
  <pre><code>zookeeper@zookeeper-0:/usr/bin$ cat /etc/hosts
  # Kubernetes-managed hosts file.
  127.0.0.1       localhost
  ::1     localhost ip6-localhost ip6-loopback
  fe00::0 ip6-localnet
  fe00::0 ip6-mcastprefix
  fe00::1 ip6-allnodes
  fe00::2 ip6-allrouters
  10.32.0.11      zookeeper-0.zookeeper-svc.default.svc.cluster.local     zookeeper-0
  </code></pre>
  
  <p>But looking for the IP</p>
  
  <p>kb exec dnsutils nslookup zookeeper-0<br>
  Server:         10.96.0.10
  Address:        10.96.0.10#53</p>
  
  <p>** server can't find zookeeper-0: NXDOMAIN</p>
  
  <p>I cannot see it.</p>
  
  <p>Where am I wrong?
  Any suggestion is appreciated.</p>