<p>I am setting up VerneMQ (a MQTT broker) in a cluster configuration. Therefore I am launching 4 replicas in a stateful set. Apparently VerneMQ wants to communicate with the other brokers in a cluster via DNS like this:</p>

<pre><code>echo "Will join an existing Kubernetes cluster with discovery node at 
${kube_pod_name}.${VERNEMQ_KUBERNETES_SUBDOMAIN}.${DOCKER_VERNEMQ_KUBERNETES_NAMESPACE}.svc.cluster.local"
</code></pre>

<p>Unfortunately the logs indicate that this doesn't work:</p>

<blockquote>
  <p>14:05:56.741 [info] Application vmq_server started on node
  'VerneMQ@broker-vernemq-0.broker-vernemq.messaging.svc.cluster.local'</p>
</blockquote>

<p><code>broker-vernemq-0</code> is the pod's name and <code>broker-vernemq</code> is the name of the statefulset. The service is configured as LoadBalancer.</p>

<p><strong>The problem:</strong></p>

<p>I connected to the pod <code>broker-vernemq-1</code> via terminal and executed <code>ping broker-vernemq-0</code> and I wondered that it is not able to resolve this hostname:</p>

<blockquote>
  <p>ping: unknown host broker-vernemq-0</p>
</blockquote>

<p>I was under the impression that this is supposed to work?</p>

<p>The service must be headless for kube-dns to service domain names like that. See <a href="https://stackoverflow.com/a/46638059">https://stackoverflow.com/a/46638059</a></p>
