mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add etcd on k8s example
This commit is contained in:
parent
18ecc297bc
commit
cfb3522b63
21
hack/kubernetes-deploy/README.md
Normal file
21
hack/kubernetes-deploy/README.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# etcd on Kubernetes
|
||||||
|
|
||||||
|
This is an example setting up etcd as a set of pods and services running on top of kubernetes. Using:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kubectl create -f etcd.yml
|
||||||
|
services/etcd-client
|
||||||
|
pods/etcd0
|
||||||
|
services/etcd0
|
||||||
|
pods/etcd1
|
||||||
|
services/etcd1
|
||||||
|
pods/etcd2
|
||||||
|
services/etcd2
|
||||||
|
$ # now deploy a service that consumes etcd, such as vulcand
|
||||||
|
$ kubectl create -f vulcand.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
|
||||||
|
- create a replication controller like service that knows how to add and remove nodes from the cluster correctly
|
||||||
|
- use kubernetes secrets API to configure TLS for etcd clients and peers
|
189
hack/kubernetes-deploy/etcd.yml
Normal file
189
hack/kubernetes-deploy/etcd.yml
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: etcd-client
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: etcd-client-port
|
||||||
|
port: 2379
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2379
|
||||||
|
selector:
|
||||||
|
app: etcd
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: etcd
|
||||||
|
etcd_node: etcd0
|
||||||
|
name: etcd0
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- /etcd
|
||||||
|
- -name
|
||||||
|
- etcd0
|
||||||
|
- -initial-advertise-peer-urls
|
||||||
|
- http://etcd0:2380
|
||||||
|
- -listen-peer-urls
|
||||||
|
- http://0.0.0.0:2380
|
||||||
|
- -listen-client-urls
|
||||||
|
- http://0.0.0.0:2379
|
||||||
|
- -advertise-client-urls
|
||||||
|
- http://etcd0:2379
|
||||||
|
- -initial-cluster
|
||||||
|
- etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
|
||||||
|
- -initial-cluster-state
|
||||||
|
- new
|
||||||
|
image: quay.io/coreos/etcd:latest
|
||||||
|
name: etcd0
|
||||||
|
ports:
|
||||||
|
- containerPort: 2379
|
||||||
|
name: client
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 2380
|
||||||
|
name: server
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Never
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
etcd_node: etcd0
|
||||||
|
name: etcd0
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: client
|
||||||
|
port: 2379
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2379
|
||||||
|
- name: server
|
||||||
|
port: 2380
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2380
|
||||||
|
selector:
|
||||||
|
etcd_node: etcd0
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: etcd
|
||||||
|
etcd_node: etcd1
|
||||||
|
name: etcd1
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- /etcd
|
||||||
|
- -name
|
||||||
|
- etcd1
|
||||||
|
- -initial-advertise-peer-urls
|
||||||
|
- http://etcd1:2380
|
||||||
|
- -listen-peer-urls
|
||||||
|
- http://0.0.0.0:2380
|
||||||
|
- -listen-client-urls
|
||||||
|
- http://0.0.0.0:2379
|
||||||
|
- -advertise-client-urls
|
||||||
|
- http://etcd1:2379
|
||||||
|
- -initial-cluster
|
||||||
|
- etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
|
||||||
|
- -initial-cluster-state
|
||||||
|
- new
|
||||||
|
image: quay.io/coreos/etcd:latest
|
||||||
|
name: etcd1
|
||||||
|
ports:
|
||||||
|
- containerPort: 2379
|
||||||
|
name: client
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 2380
|
||||||
|
name: server
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Never
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
etcd_node: etcd1
|
||||||
|
name: etcd1
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: client
|
||||||
|
port: 2379
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2379
|
||||||
|
- name: server
|
||||||
|
port: 2380
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2380
|
||||||
|
selector:
|
||||||
|
etcd_node: etcd1
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: etcd
|
||||||
|
etcd_node: etcd2
|
||||||
|
name: etcd2
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- /etcd
|
||||||
|
- -name
|
||||||
|
- etcd2
|
||||||
|
- -initial-advertise-peer-urls
|
||||||
|
- http://etcd2:2380
|
||||||
|
- -listen-peer-urls
|
||||||
|
- http://0.0.0.0:2380
|
||||||
|
- -listen-client-urls
|
||||||
|
- http://0.0.0.0:2379
|
||||||
|
- -advertise-client-urls
|
||||||
|
- http://etcd2:2379
|
||||||
|
- -initial-cluster
|
||||||
|
- etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
|
||||||
|
- -initial-cluster-state
|
||||||
|
- new
|
||||||
|
image: quay.io/coreos/etcd:latest
|
||||||
|
name: etcd2
|
||||||
|
ports:
|
||||||
|
- containerPort: 2379
|
||||||
|
name: client
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 2380
|
||||||
|
name: server
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Never
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
etcd_node: etcd2
|
||||||
|
name: etcd2
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: client
|
||||||
|
port: 2379
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2379
|
||||||
|
- name: server
|
||||||
|
port: 2380
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 2380
|
||||||
|
selector:
|
||||||
|
etcd_node: etcd2
|
22
hack/kubernetes-deploy/vulcand.yml
Normal file
22
hack/kubernetes-deploy/vulcand.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: vulcand
|
||||||
|
name: vulcand
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- command:
|
||||||
|
- /go/bin/vulcand
|
||||||
|
- -apiInterface=0.0.0.0
|
||||||
|
- --etcd=http://etcd-client:2379
|
||||||
|
image: mailgun/vulcand:v0.8.0-beta.2
|
||||||
|
name: vulcand
|
||||||
|
ports:
|
||||||
|
- containerPort: 8081
|
||||||
|
name: api
|
||||||
|
protocol: TCP
|
||||||
|
- containerPort: 8082
|
||||||
|
name: server
|
||||||
|
protocol: TCP
|
||||||
|
restartPolicy: Always
|
Loading…
x
Reference in New Issue
Block a user