github.com/lingyao2333/mo-zero@v1.4.1/core/discov/kubernetes/etcd-statefulset.yaml (about) 1 apiVersion: apps/v1 2 kind: StatefulSet 3 metadata: 4 name: "etcd" 5 namespace: discov 6 labels: 7 app: "etcd" 8 spec: 9 serviceName: "etcd" 10 replicas: 5 11 template: 12 metadata: 13 name: "etcd" 14 labels: 15 app: "etcd" 16 spec: 17 volumes: 18 - name: etcd-pvc 19 persistentVolumeClaim: 20 claimName: etcd-pvc 21 containers: 22 - name: "etcd" 23 image: quay.io/coreos/etcd:latest 24 ports: 25 - containerPort: 2379 26 name: client 27 - containerPort: 2380 28 name: peer 29 env: 30 - name: CLUSTER_SIZE 31 value: "5" 32 - name: SET_NAME 33 value: "etcd" 34 - name: VOLNAME 35 valueFrom: 36 fieldRef: 37 apiVersion: v1 38 fieldPath: metadata.name 39 volumeMounts: 40 - name: etcd-pvc 41 mountPath: /var/lib/etcd 42 subPathExpr: $(VOLNAME) # data mounted respectively in each pod 43 command: 44 - "/bin/sh" 45 - "-ecx" 46 - | 47 48 chmod 700 /var/lib/etcd 49 50 IP=$(hostname -i) 51 PEERS="" 52 for i in $(seq 0 $((${CLUSTER_SIZE} - 1))); do 53 PEERS="${PEERS}${PEERS:+,}${SET_NAME}-${i}=http://${SET_NAME}-${i}.${SET_NAME}:2380" 54 done 55 exec etcd --name ${HOSTNAME} \ 56 --listen-peer-urls http://0.0.0.0:2380 \ 57 --listen-client-urls http://0.0.0.0:2379 \ 58 --advertise-client-urls http://${HOSTNAME}.${SET_NAME}.discov:2379 \ 59 --initial-advertise-peer-urls http://${HOSTNAME}.${SET_NAME}:2380 \ 60 --initial-cluster ${PEERS} \ 61 --initial-cluster-state new \ 62 --logger zap \ 63 --data-dir /var/lib/etcd \ 64 --auto-compaction-retention 1