87 lines
2.1 KiB
YAML
87 lines
2.1 KiB
YAML
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: etcd-dns
|
|
namespace: dns
|
|
spec:
|
|
ports:
|
|
- name: etcd-client
|
|
port: 2379
|
|
protocol: TCP
|
|
- name: etcd-peer
|
|
port: 2380
|
|
protocol: TCP
|
|
selector:
|
|
app: etcd-dns
|
|
publishNotReadyAddresses: true
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: etcd-dns
|
|
namespace: dns
|
|
labels:
|
|
app: etcd-dns
|
|
spec:
|
|
serviceName: "etcd-dns"
|
|
replicas: 3
|
|
selector:
|
|
matchLabels:
|
|
app: etcd-dns
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: etcd-dns
|
|
spec:
|
|
containers:
|
|
- name: etcd-dns
|
|
image: quay.io/coreos/etcd:latest
|
|
ports:
|
|
- containerPort: 2379
|
|
name: client
|
|
- containerPort: 2380
|
|
name: peer
|
|
env:
|
|
- name: CLUSTER_SIZE
|
|
value: "3"
|
|
- name: SET_NAME
|
|
value: "etcd-dns"
|
|
volumeMounts:
|
|
- name: datadir
|
|
mountPath: /var/run/etcd
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
IP=$(hostname -i)
|
|
PEERS=""
|
|
for i in $(seq 0 $((${CLUSTER_SIZE} - 1))); do
|
|
PEERS="${PEERS}${PEERS:+,}${SET_NAME}-${i}=http://${SET_NAME}-${i}.${SET_NAME}:2380"
|
|
done
|
|
|
|
exec /usr/local/bin/etcd --name ${HOSTNAME} \
|
|
--listen-peer-urls http://${IP}:2380 \
|
|
--listen-client-urls http://${IP}:2379,http://127.0.0.1:2379 \
|
|
--advertise-client-urls http://${HOSTNAME}.${SET_NAME}:2379 \
|
|
--initial-advertise-peer-urls http://${HOSTNAME}.${SET_NAME}:2380 \
|
|
--initial-cluster-token etcd-cluster-1 \
|
|
--initial-cluster ${PEERS} \
|
|
--initial-cluster-state new \
|
|
--data-dir /var/run/etcd/default.etcd
|
|
ports:
|
|
- containerPort: 2379
|
|
name: client
|
|
protocol: TCP
|
|
- containerPort: 2380
|
|
name: peer
|
|
protocol: TCP
|
|
volumeClaimTemplates:
|
|
- metadata:
|
|
name: datadir
|
|
spec:
|
|
accessModes:
|
|
- "ReadWriteOnce"
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|