backup.yaml 2.76 KB
apiVersion: batch/v1
kind: CronJob
metadata:
  name: backup-secrets-do-backup
  annotations:
    helm.sh/hook: post-install,post-upgrade
spec:
  schedule: "13 * * * *"
  startingDeadlineSeconds: 3600
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 10
  failedJobsHistoryLimit: 10
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: backup-secrets
          restartPolicy: OnFailure
          volumes:
            - name: work-space
              emptyDir: {}
            - name: config
              configMap:
                name: backup-secrets-config
            - name: auth
              secret:
                secretName: backup-secrets-auth
            - name: scripts
              configMap:
                name: backup-secrets-scripts
                defaultMode: 0755
          initContainers:
            - name: list-s3
              image: peakcom/s5cmd
              command: ["/scripts/backup"]
              args: ["list-s3"]
              volumeMounts:
                - name: work-space
                  mountPath: /work-space
                - name: config
                  mountPath: /config
                - name: auth
                  mountPath: /auth
                - name: scripts
                  mountPath: /scripts

            - name: calculate-delete-s3
              image: debian
              command: ["/scripts/backup"]
              args: ["calculate-delete-s3"]
              volumeMounts:
                - name: work-space
                  mountPath: /work-space
                - name: config
                  mountPath: /config
                - name: scripts
                  mountPath: /scripts

            - name: create-secrets-tarball
              image: bitnami/kubectl
              command: ["/scripts/backup"]
              args: ["create-secrets-tarball"]
              volumeMounts:
                - name: work-space
                  mountPath: /work-space
                - name: scripts
                  mountPath: /scripts


            - name: copy-to-s3
              image: peakcom/s5cmd
              command: ["/scripts/backup"]
              args: ["copy-to-s3"]
              volumeMounts:
                - name: work-space
                  mountPath: /work-space
                - name: config
                  mountPath: /config
                - name: auth
                  mountPath: /auth
                - name: scripts
                  mountPath: /scripts

          containers:
            - name: show-backup
              image: debian
              command: ["/scripts/backup"]
              args: ["show-backup"]
              volumeMounts:
                - name: work-space
                  mountPath: /work-space
                - name: scripts
                  mountPath: /scripts