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?
Kubernetes defines a network model called the container network interface (CNI), but the actual implementation relies on network plugins. The network plugin is responsible for allocating internet protocol (IP) addresses to pods and enabling pods to communicate with each other within the Kubernetes cluster.
Kubernetes pods can't ping each other using ClusterIP - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Kubernetes assumes that pods can communicate with other pods, regardless of which host they land on. Kubernetes gives every pod its own cluster-private IP address, so you do not need to explicitly create links between pods or map container ports to host ports.
To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With