backup.yaml 3.64 KB
apiVersion: batch/v1
kind: CronJob
metadata:
  name: backup-secrets-do-backup
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
            - name: aws-config
              configMap:
                name: backup-secrets-config
                items:
                  - key: config
                    path: config
            - name: aws-credentials
              secret:
                secretName: backup-secrets-auth
                items:
                  - key: credentials
                    path: credentials
          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

                - mountPath: /root/.aws/config
                  name: aws-config
                  subPath: config
                - mountPath: /root/.aws/credentials
                  name: aws-credentials
                  subPath: credentials

            - 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: config
                  mountPath: /config
                - 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

                - mountPath: /root/.aws/config
                  name: aws-config
                  subPath: config
                - mountPath: /root/.aws/credentials
                  name: aws-credentials
                  subPath: credentials

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