From 3d39bd986e274e543e037a88d42469b9bd4bd392 Mon Sep 17 00:00:00 2001 From: Mustafa Elbehery Date: Sun, 30 Jun 2024 16:16:51 +0200 Subject: [PATCH] ETCD-636: add automated backup side car --- bindata/etcd/pod.yaml | 32 +++++++++++++++++++++++++++++ pkg/operator/etcd_assets/bindata.go | 32 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/bindata/etcd/pod.yaml b/bindata/etcd/pod.yaml index 1b94d519f6..8af892ab37 100644 --- a/bindata/etcd/pod.yaml +++ b/bindata/etcd/pod.yaml @@ -129,6 +129,34 @@ ${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 + + sudo 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 +363,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..74d9b41dbc 100644 --- a/pkg/operator/etcd_assets/bindata.go +++ b/pkg/operator/etcd_assets/bindata.go @@ -1045,6 +1045,34 @@ ${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 + + sudo 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 +1279,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) {