<p>I am working on a Kubernetes integration of the database Apache IoTDB which supports a Cluster mode. Currently, to start a cluster each node needs to know the IP adresses of all other nodes in its &quot;ensemble&quot; upfront, before starting.</p>
<p>I think the default approach to this in Kubernetes would generally be to use a StatefulSet and a headless Service. And the startup loop I scratched would be something like this</p>
<ol>
<li>start each pod with a container which contains a &quot;pre-start&quot; script</li>
<li>In the pre-start script wait until all other pods of the set are started and get all their ip adresses from the headless service)</li>
<li>update the configs / env variables with all cluster ip adresses</li>
<li>start the iotdb instance(s)</li>
</ol>
<p>So the only question I have is for step 2: When do I know that all pods are started?
Is the update of the DNS / A records of the headless Service atomic in the sense that I see all pods or no pod?
OR do I have to query the API Server separately to see the number of replicas and then wait until I got all their records from the headless service?</p>
<p>Or is there a more kubernetes-like way to achieve that?</p>
<p>Thanks already!</p>

<p>When a DNS address of a headless service is resolved, it returns a list of Pods (ie. IPs) from an underlying endpoint object. The endpoint object always holds the list of <strong>Ready</strong> pods.</p>
<p>So, you will get the list of <strong>Ready</strong> pods of that moment on resolving headless service DNS.</p>
