I have a pod/service running an application that consumes etcd as a synchronization system and datastore. I want to run etcd within the pod, such that all of the replicas form a coherent cluster. In other words, so 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.
我有一个pod/服务运行一个应用程序,它使用etcd作为同步系统和数据存储。我想在pod中运行etcd,这样所有的副本都形成一个连贯的集群。换句话说,因此副本#1中的应用程序可以将“foo”写入localhost:4001/v2/keys/my_key,然后第二个副本#2可以读取localhost:4001/v2/keys/my_key,然后得到“foo”。
It's not clear how this can be done, since pod replicas are not individually addressable. I could in theory create an "etcd" service exposing the cluster ports, but any requests would round-robin to all the replicas so the individual etcd nodes would not be able to find each other.
目前尚不清楚这是如何实现的,因为pod副本不是单独可寻址的。理论上,我可以创建一个暴露集群端口的“etcd”服务,但是任何请求都将对所有副本进行循环,这样每个etcd节点就无法找到彼此。
Am I approaching this problem the correct way?
我处理这个问题的方法正确吗?
3 个解决方案
#1
2
You can deploy etcd on kubernetes using an Operator (from the extensions/v1beta1
) and the quay.io/coreos/etcd-operator
image.
您可以使用操作符(来自扩展名/v1beta1)和码头在kubernetes上部署etcd。io / coreos etcd-operator形象。
An example deployment with a cluster size of 3 looks like this:
一个集群大小为3的部署示例如下:
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"
Please be aware of the beta status of this project. However according to the maintainers the operator is now stable. I have deployed the configuration above successfully but I didn't run any of this in production.
请注意这个项目的beta状态。但是根据维护人员的说法,该操作现在是稳定的。我已经成功地部署了上面的配置,但是我没有在生产中运行这些配置。
The operator code is available on github. You can find additional documentation there.
操作符代码可以在github上找到。您可以在那里找到其他文档。
#2
1
There's a pretty good example of a three node etcd cluster here: https://github.com/coreos/etcd/tree/master/hack/kubernetes-deploy
这里有一个很好的三个节点etcd集群示例:https://github.com/coreos/etcd/tree/master/hack/kubernetes-deploy
They make use of separate rc's and services for each replica as a workaround until nominal services are added.
它们利用每个副本的独立rc和服务作为解决方案,直到添加名义上的服务。
#3
0
I added your question to kubernetes/kubernetes#5017
我把你的问题加到了kubernetes/kubernetes#5017
If someone knows the answer, they will hopefully post it there.
如果有人知道答案,他们会希望把它贴在那里。
I think it may require the "nominal services" feature (kubernetes/kubernetes#260) which is not implemented yet, but I'm not sure.
我认为它可能需要“名义服务”功能(kubernetes/kubernetes#260),但我不确定。
#1
2
You can deploy etcd on kubernetes using an Operator (from the extensions/v1beta1
) and the quay.io/coreos/etcd-operator
image.
您可以使用操作符(来自扩展名/v1beta1)和码头在kubernetes上部署etcd。io / coreos etcd-operator形象。
An example deployment with a cluster size of 3 looks like this:
一个集群大小为3的部署示例如下:
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"
Please be aware of the beta status of this project. However according to the maintainers the operator is now stable. I have deployed the configuration above successfully but I didn't run any of this in production.
请注意这个项目的beta状态。但是根据维护人员的说法,该操作现在是稳定的。我已经成功地部署了上面的配置,但是我没有在生产中运行这些配置。
The operator code is available on github. You can find additional documentation there.
操作符代码可以在github上找到。您可以在那里找到其他文档。
#2
1
There's a pretty good example of a three node etcd cluster here: https://github.com/coreos/etcd/tree/master/hack/kubernetes-deploy
这里有一个很好的三个节点etcd集群示例:https://github.com/coreos/etcd/tree/master/hack/kubernetes-deploy
They make use of separate rc's and services for each replica as a workaround until nominal services are added.
它们利用每个副本的独立rc和服务作为解决方案,直到添加名义上的服务。
#3
0
I added your question to kubernetes/kubernetes#5017
我把你的问题加到了kubernetes/kubernetes#5017
If someone knows the answer, they will hopefully post it there.
如果有人知道答案,他们会希望把它贴在那里。
I think it may require the "nominal services" feature (kubernetes/kubernetes#260) which is not implemented yet, but I'm not sure.
我认为它可能需要“名义服务”功能(kubernetes/kubernetes#260),但我不确定。