...
1apiVersion: v1
2kind: Service
3metadata:
4 name: etcd
5 labels:
6 app: etcd
7 component: infra
8spec:
9 clusterIP: None
10 ports:
11 - port: 2379
12 protocol: TCP
13 targetPort: 2379
14 name: client
15 - port: 2380
16 targetPort: 2380
17 protocol: TCP
18 name: peer
19 selector:
20 app: etcd
21---
22apiVersion: apps/v1
23kind: StatefulSet
24metadata:
25 name: etcd
26spec:
27 serviceName: etcd
28 replicas: 3
29 template:
30 metadata:
31 labels:
32 app: etcd
33 component: infra
34 annotations:
35 prometheus.io.scrape: "true"
36 prometheus.io.port: "2379"
37 spec:
38 affinity:
39 podAntiAffinity:
40 requiredDuringSchedulingIgnoredDuringExecution:
41 - labelSelector:
42 matchExpressions:
43 - key: "app"
44 operator: In
45 values:
46 - etcd
47 topologyKey: "kubernetes.io/hostname"
48 terminationGracePeriodSeconds: 10
49 containers:
50 - name: etcd
51 image: quay.io/coreos/etcd:v3.3.10
52 ports:
53 - name: client
54 containerPort: 2379
55 - name: peer
56 containerPort: 2380
57 livenessProbe:
58 httpGet:
59 path: /health
60 port: client
61 initialDelaySeconds: 30
62 volumeMounts:
63 - name: etcd3
64 mountPath: /data
65 env:
66 - name: ETCDCTL_API
67 value: "3"
68 - name: ETCD_AUTO_COMPACTION_RETENTION
69 value: "4"
70 - name: NAME
71 valueFrom:
72 fieldRef:
73 fieldPath: metadata.name
74 - name: IP
75 valueFrom:
76 fieldRef:
77 fieldPath: status.podIP
78 command: ["/usr/local/bin/etcd"]
79 args: [
80 "-name", "$(NAME)",
81 "-data-dir", "/data/etcd3",
82 "-initial-advertise-peer-urls", "http://$(IP):2380",
83 "-listen-peer-urls", "http://$(IP):2380",
84 "-listen-client-urls", "http://$(IP):2379,http://127.0.0.1:2379",
85 "-advertise-client-urls", "http://$(IP):2379",
86 # bootstrap
87 # "-initial-cluster-token", "etcd-prod-events2",
88 "-discovery", "https://discovery.etcd.io/xxxxxx",
89 ]
90 volumeClaimTemplates:
91 - metadata:
92 name: etcd3
93 annotations:
94 volume.alpha.kubernetes.io/storage-class: default
95 spec:
96 accessModes: [ "ReadWriteOnce" ]
97 resources:
98 requests:
99 storage: 10Gi
View as plain text