How to start cluster etcd among pod replicas?

I have pod / service running an application that consumes etcd as a synchronization system and data warehouse. I want to run etcd inside pod so that all the replicas form a coherent cluster. In other words, the application in replica # 1 can write “foo” to localhost:4001/v2/keys/my_key , and then replica # 2 can then read localhost:4001/v2/keys/my_key and get “foo” as a result.

It is not clear how this can be done, since pod replicas are not individually addressed. I could theoretically create an "etcd" service that displays the cluster ports, but any requests will be cyclically distributed across all replicas so that the individual nodes of etcd cannot find each other.

Am I right on this issue?

+7
kubernetes etcd
source share
3 answers

You can deploy etcd on the kubernet using the operator (from extensions/v1beta1 ) and quay.io/coreos/etcd-operator .

An example deployment with cluster size 3 is as follows:

 apiVersion: extensions/v1beta1 kind: Deployment metadata: name: etcd-operator spec: replicas: 1 template: metadata: name: etcd-operator labels: app: etcd component: operator spec: containers: - name: etcd-operator image: quay.io/coreos/etcd-operator:v0.3.0 env: - name: MY_POD_NAMESPACE valueFrom: { fieldRef: { fieldPath: metadata.namespace } } - name: MY_POD_NAME valueFrom: { fieldRef: { fieldPath: metadata.name } } --- apiVersion: etcd.coreos.com/v1beta1 kind: Cluster metadata: name: etcd-cluster labels: app: etcd component: cluster spec: size: 3 version: "3.1.8" 

Pay attention to the beta status of this project. However, according to the attendants, the operator is now stable . I successfully deployed the configuration above, but I did not run it during production.

The operator code is available on github . You can find additional documentation here.

+2
source share

Here is a pretty good example of three node etcd clusters: https://github.com/coreos/etcd/tree/master/hack/kubernetes-deploy

They use separate rc and services for each replica as a workaround until nominee services are added.

+1
source share

I added your question to kubernetes / kubernetes # 5017

If someone knows the answer, he will hopefully post it there.

I think this may require the “nominee services” function ( kubernetes / kubernetes # 260 ), which is not yet implemented, but I'm not sure.

0
source share

All Articles