<p>I'm trying to create two kubernetes services, one which is a loadbalancer with a cluster IP, and another which is a headless (no cluster IP), but instead returns an A record round robin collection of the pod ip addresses (as it should do, according to <a href="http://kubernetes.io/docs/user-guide/services/#headless-services" rel="nofollow">http://kubernetes.io/docs/user-guide/services/#headless-services</a>).</p>

<p>I need to do this because I need a dynamic collection of pod ip's in order to do auto clustering and service discovery.</p>

<p>My services look like this:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: rabbitmq
  labels:
    app: rabbitmq
    tier: messaging
spec:
  ports:
  - name: amqp
    port: 5672
    targetPort: 5672
  selector:
    app: rabbitmq
    tier: messaging
---
apiVersion: v1
kind: Service
metadata:
  name: rabbitmq-cluster
  labels:
    app: rabbitmq
    tier: messaging
spec:
  clusterIP: None
  ports:
  - name: amqp
    port: 5672
    targetPort: 5672
  selector:
    app: rabbitmq
    tier: messaging
</code></pre>

<p>With these two services, i get the following:</p>

<pre><code>$ kubectl get services
NAME               CLUSTER-IP      EXTERNAL-IP       PORT(S)     AGE
rabbitmq           10.23.255.174   &lt;none&gt;            5672/TCP    7m
rabbitmq-cluster   None            &lt;none&gt;            5672/TCP    7m
</code></pre>

<p>And DNS (from another pod) for the cluster IP works:</p>

<pre><code>[root@gateway-3738159135-a7wp9 app]# nslookup rabbitmq.td-integration
Server:     10.23.240.10
Address:        10.23.240.10#53

Name:   rabbitmq.td-integration.svc.cluster.local
Address: 10.23.255.174
</code></pre>

<p>However, the dns for the 'headless' service, doesn't return:</p>

<pre><code>[root@gateway-3738159135-a7wp9 app]# nslookup rabbitmq-cluster.td-integration
Server:     10.23.240.10
Address:        10.23.240.10#53

** server can't find rabbitmq-cluster.td-integration: NXDOMAIN
</code></pre>

<p>It seems like there is no pod matching these labels within your cluster, therefore the DNS query doesn't return anything. This is expected.</p>

<p>Start the corresponding pods and you should see a list of A records.</p>

<p>Please be aware that these A records are not shuffled as far as I know, so your clients are expected to consume the DNS answer and perform their own round robin.</p>
