add etcd on k8s example

This commit is contained in:
Alex Polvi 2015-08-12 21:32:25 +03:00
parent 18ecc297bc
commit cfb3522b63
3 changed files with 232 additions and 0 deletions

View 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

View 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

View 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