apiVersion: apps/v1 kind: Deployment metadata: name: etcd-deploy labels: app: etcd spec: replicas: 1 selector: matchLabels: app: etcd template: metadata: labels: app: etcd spec: containers: - name: etcd image: quay.io/coreos/etcd:latest ports: - containerPort: 2379 name: client protocol: TCP - containerPort: 2380 name: server protocol: TCP command: - /usr/local/bin/etcd - --name - etcd - --initial-advertise-peer-urls - http://etcd:2380 - --listen-peer-urls - http://0.0.0.0:2380 - --listen-client-urls - http://0.0.0.0:2379 - --advertise-client-urls - http://etcd:2379 - --initial-cluster - etcd=http://etcd:2380 - --data-dir - /etcd-data volumeMounts: - mountPath: /etcd-data name: etcd-data lifecycle: postStart: exec: command: - "sh" - "-c" - > echo "127.0.0.1 etcd" >> /etc/hosts; volumes: - name: etcd-data persistentVolumeClaim: claimName: k8s-etcd-20g restartPolicy: Always