From 05e94f10f07eb797f7cc2eccd86fd8172a4f5fbe Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Fri, 7 Feb 2025 13:15:20 +0100 Subject: [PATCH] Add cronjob --- backups/base/backup-cronjob.yaml | 47 +++++++++++++++++++ backups/base/kustomization.yaml | 2 + .../overlays/test/xrootd/backup-cronjob.yaml | 37 +++++++++++++++ .../overlays/test/xrootd/kustomization.yaml | 7 +++ 4 files changed, 93 insertions(+) create mode 100644 backups/base/backup-cronjob.yaml create mode 100644 backups/base/kustomization.yaml create mode 100644 backups/overlays/test/xrootd/backup-cronjob.yaml create mode 100644 backups/overlays/test/xrootd/kustomization.yaml diff --git a/backups/base/backup-cronjob.yaml b/backups/base/backup-cronjob.yaml new file mode 100644 index 0000000..9466a94 --- /dev/null +++ b/backups/base/backup-cronjob.yaml @@ -0,0 +1,47 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: backup +spec: + schedule: "0 0 * * *" + jobTemplate: + spec: + volumes: + - name: backup-storage + emptyDir: {} + restartPolicy: Never + containers: + - name: backup-container + image: docker.sunet.se/drive/duplicity:bookworm-slim-1 + args: ["backup", "/backup_storage", "destination:${BUCKET}"] + env: + - name: RCLONE_CONFIG_DESTINATION_ACL + value: private + - name: RCLONE_CONFIG_DESTINATION_TYPE + value: s3 + - name: RCLONE_CONFIG_DESTINATION_ENDPOINT + value: s3.sto3.safedc.net + - name: RCLONE_CONFIG_DESTINATION_PROVIDER + value: Ceph + volumeMounts: + - name: backup-storage + mountPath: /backup_storage + mountPropagation: HostToContainer + - name: mount-container + image: rclone/rclone:1.69.0 + securityContext: + privileged: true + args: ["mount", "source:${BUCKET}", "/backup_storage"] + env: + - name: RCLONE_CONFIG_SOURCE_ACL + value: private + - name: RCLONE_CONFIG_SOURCE_TYPE + value: s3 + - name: RCLONE_CONFIG_SOURCE_ENDPOINT + value: s3.sto4.safedc.net + - name: RCLONE_CONFIG_SOURCE_PROVIDER + value: Ceph + volumeMounts: + - name: backup-storage + mountPath: /backup_storage + mountPropagation: Bidirectional diff --git a/backups/base/kustomization.yaml b/backups/base/kustomization.yaml new file mode 100644 index 0000000..b534140 --- /dev/null +++ b/backups/base/kustomization.yaml @@ -0,0 +1,2 @@ +resources: + - backup-cronjob.yaml diff --git a/backups/overlays/test/xrootd/backup-cronjob.yaml b/backups/overlays/test/xrootd/backup-cronjob.yaml new file mode 100644 index 0000000..8804788 --- /dev/null +++ b/backups/overlays/test/xrootd/backup-cronjob.yaml @@ -0,0 +1,37 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: backup +spec: + schedule: "0 14 * * *" + jobTemplate: + spec: + containers: + - name: backup-container + env: + - name: BUCKET + value: "xrootd-test-mirror" + - name: RCLONE_CONFIG_DESTINATION_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: xrootd-secret + key: "destination-access-key-id" + - name: RCLONE_CONFIG_DESTINATION_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: xrootd-secret + key: "destination-secret-access-key" + - name: mount-container + env: + - name: BUCKET + value: "xrootd-test" + - name: RCLONE_CONFIG_SOURCE_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: xrootd-secret + key: "source-access-key-id" + - name: RCLONE_CONFIG_SOURCE_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: xrootd-secret + key: "source-secret-access-key" diff --git a/backups/overlays/test/xrootd/kustomization.yaml b/backups/overlays/test/xrootd/kustomization.yaml new file mode 100644 index 0000000..06bf611 --- /dev/null +++ b/backups/overlays/test/xrootd/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: 'kustomize.config.k8s.io/v1beta1' +kind: Kustomization +bases: +- ../../../base +patchesStrategicMerge: + - backup-cronjob.yaml +