<p>I am trying to implement something like the etcd services that uses the consensus algorithm (<a href="https://raft.github.io/" rel="noreferrer">https://raft.github.io/</a>). In this case, multiple instances of the etcd services need to be aware of each other. For this to happen, if we have 3 pods of etcd instance in a replication controller, the pods need to be able to talk to each other (at least be able to know the IP of self and all the other pods).</p>

<p>Is there a way of achieving this in the replication controller or pod specs without having to use the kubernetes API in the pod container?</p>

<p>You can put a service in front of those pods by giving each pod some label (for example <code>etcd-service=true</code>), and making a kubernetes service with a selector that matches that label.  Use the DNS add-on, and you will get a DNS A record for each endpoint in the service.  You can read more in the docs <a href="https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/services.md#discovering-services" rel="nofollow">here</a>.</p>
