diff --git a/bindata/etcd/pod.yaml b/bindata/etcd/pod.yaml index 1b94d519f6..8d312870aa 100644 --- a/bindata/etcd/pod.yaml +++ b/bindata/etcd/pod.yaml @@ -129,6 +129,33 @@ ${COMPUTED_ENV_VARS} ${COMPUTED_ENV_VARS} - name: "ETCD_STATIC_POD_VERSION" value: "REVISION" + # The etcdbackup container copies snapshots from etcd data dir into backup volume. + - name: etcdbackup + image: ${IMAGE} + imagePullPolicy: IfNotPresent + terminationMessagePolicy: FallbackToLogsOnError + command: + - /bin/sh + - -c + - | + #!/bin/sh + set -euo pipefail + cp --verbose --recursive --preserve --reflink=auto /var/lib/etcd/ /var/backup/etcd + resources: + requests: + memory: 60Mi + cpu: 10m + volumeMounts: + - mountPath: /etc/kubernetes/manifests + name: static-pod-dir + - mountPath: /etc/kubernetes/static-pod-resources + name: resource-dir + - mountPath: /etc/kubernetes/static-pod-certs + name: cert-dir + - mountPath: /var/lib/etcd/ + name: data-dir + - mountPath: /var/backup/etcd + name: backup-dir - name: etcd image: ${IMAGE} imagePullPolicy: IfNotPresent @@ -335,3 +362,7 @@ ${COMPUTED_ENV_VARS} - hostPath: path: /var/log/etcd name: log-dir + - hostPath: + path: /var/backup/etcd + type: "" + name: backup-dir diff --git a/pkg/operator/etcd_assets/bindata.go b/pkg/operator/etcd_assets/bindata.go index f8e67500d6..b77d025f5e 100644 --- a/pkg/operator/etcd_assets/bindata.go +++ b/pkg/operator/etcd_assets/bindata.go @@ -1045,6 +1045,31 @@ ${COMPUTED_ENV_VARS} ${COMPUTED_ENV_VARS} - name: "ETCD_STATIC_POD_VERSION" value: "REVISION" + # The etcdbackup container copies snapshots from etcd data dir into backup volume. + - name: etcdbackup + image: ${IMAGE} + imagePullPolicy: IfNotPresent + terminationMessagePolicy: FallbackToLogsOnError + command: + - /bin/sh + - -c + - | + cp --verbose --recursive --preserve --reflink=auto /var/lib/etcd/ /var/backup/etcd + resources: + requests: + memory: 60Mi + cpu: 10m + volumeMounts: + - mountPath: /etc/kubernetes/manifests + name: static-pod-dir + - mountPath: /etc/kubernetes/static-pod-resources + name: resource-dir + - mountPath: /etc/kubernetes/static-pod-certs + name: cert-dir + - mountPath: /var/lib/etcd/ + name: data-dir + - mountPath: /var/backup/etcd + name: backup-dir - name: etcd image: ${IMAGE} imagePullPolicy: IfNotPresent @@ -1251,6 +1276,10 @@ ${COMPUTED_ENV_VARS} - hostPath: path: /var/log/etcd name: log-dir + - hostPath: + path: /var/backup/etcd + type: "" + name: backup-dir `) func etcdPodYamlBytes() ([]byte, error) {