From f6eef6650effcd38b86c37b678f76be7ffb066e1 Mon Sep 17 00:00:00 2001 From: Mustafa Elbehery Date: Thu, 11 Jul 2024 17:25:32 +0200 Subject: [PATCH] add sidecar container --- bindata/etcd/pod.yaml | 36 +++++++++++++++++++++++++ pkg/cmd/backuprestore/backupnoconfig.go | 2 +- pkg/operator/etcd_assets/bindata.go | 36 +++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/bindata/etcd/pod.yaml b/bindata/etcd/pod.yaml index 1b94d519f6..5b17bc605b 100644 --- a/bindata/etcd/pod.yaml +++ b/bindata/etcd/pod.yaml @@ -311,6 +311,36 @@ ${COMPUTED_ENV_VARS} name: log-dir - mountPath: /etc/kubernetes/static-pod-certs name: cert-dir + - name: etcd-backup-noconfig + image: ${OPERATOR_IMAGE} + imagePullPolicy: IfNotPresent + terminationMessagePolicy: FallbackToLogsOnError + command: + - /bin/sh + - -c + - | + #!/bin/sh + set -euo pipefail + exec nice -n -18 cluster-etcd-operator backup-server \ + --endpoints=https://localhost:2379 \ + --config-dir=/etc/kubernetes \ + --data-dir=/var/lib/etcd \ + --backup-dir=/var/backup/etcd + securityContext: + privileged: true + resources: + requests: + memory: 50Mi + cpu: 10m + env: +${COMPUTED_ENV_VARS} + volumeMounts: + - mountPath: /var/lib/etcd + name: data-dir + - mountPath: /var/backup/etcd + name: backup-dir + - mountPath: /etc/kubernetes + name: config-dir hostNetwork: true priorityClassName: system-node-critical tolerations: @@ -335,3 +365,9 @@ ${COMPUTED_ENV_VARS} - hostPath: path: /var/log/etcd name: log-dir + - hostPath: + path: /var/backup/etcd + name: backup-dir + - hostPath: + path: /etc/kubernetes + name: config-dir diff --git a/pkg/cmd/backuprestore/backupnoconfig.go b/pkg/cmd/backuprestore/backupnoconfig.go index a1ff55c12d..0ff868c72a 100644 --- a/pkg/cmd/backuprestore/backupnoconfig.go +++ b/pkg/cmd/backuprestore/backupnoconfig.go @@ -59,7 +59,7 @@ func (b *backupNoConfig) AddFlags(fs *pflag.FlagSet) { } func (b *backupNoConfig) Validate() error { - return b.Validate() + return b.backupOptions.Validate() } func (b *backupNoConfig) Run() error { diff --git a/pkg/operator/etcd_assets/bindata.go b/pkg/operator/etcd_assets/bindata.go index f8e67500d6..bc28fa60dc 100644 --- a/pkg/operator/etcd_assets/bindata.go +++ b/pkg/operator/etcd_assets/bindata.go @@ -1227,6 +1227,36 @@ ${COMPUTED_ENV_VARS} name: log-dir - mountPath: /etc/kubernetes/static-pod-certs name: cert-dir + - name: etcd-backup-noconfig + image: ${OPERATOR_IMAGE} + imagePullPolicy: IfNotPresent + terminationMessagePolicy: FallbackToLogsOnError + command: + - /bin/sh + - -c + - | + #!/bin/sh + set -euo pipefail + exec nice -n -18 cluster-etcd-operator backup-server \ + --endpoints=https://localhost:2379 \ + --config-dir=/etc/kubernetes \ + --data-dir=/var/lib/etcd \ + --backup-dir=/var/backup/etcd + securityContext: + privileged: true + resources: + requests: + memory: 50Mi + cpu: 10m + env: +${COMPUTED_ENV_VARS} + volumeMounts: + - mountPath: /var/lib/etcd + name: data-dir + - mountPath: /var/backup/etcd + name: backup-dir + - mountPath: /etc/kubernetes + name: config-dir hostNetwork: true priorityClassName: system-node-critical tolerations: @@ -1251,6 +1281,12 @@ ${COMPUTED_ENV_VARS} - hostPath: path: /var/log/etcd name: log-dir + - hostPath: + path: /var/backup/etcd + name: backup-dir + - hostPath: + path: /etc/kubernetes + name: config-dir `) func etcdPodYamlBytes() ([]byte, error) {