Reputation: 73
I am trying to implement something like the etcd services that uses the consensus algorithm (https://raft.github.io/). 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).
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?
Upvotes: 6
Views: 2212
Reputation: 15788
You can put a service in front of those pods by giving each pod some label (for example etcd-service=true
), 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 here.
Upvotes: 4