restore.yaml 3.08 KB
apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    helm.sh/hook: post-install
    helm.sh/hook-weight: "-5"
    helm.sh/hook-delete-policy: before-hook-creation
#  annotations:
#    helm.sh/hook: pre-install
#    helm.sh/hook-delete-policy: before-hook-creation
#    helm.sh/hook-weight: "-5"
  name: backup-secrets-do-restore
spec:
  template:
    spec:
      restartPolicy: Never
      serviceAccountName: backup-secrets
      containers:
        - name: show-backup
          command: ["/scripts/backup"]
          args: ["show-backup"]
          image: debian
          volumeMounts:
            - mountPath: /work-space
              name: work-space
            - mountPath: /scripts
              name: scripts

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

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

        - name: calculate-restore-s3
          command: ["/scripts/backup"]
          args: ["calculate-restore-s3"]
          image: debian
          volumeMounts:
            - mountPath: /work-space
              name: work-space
            - mountPath: /config
              name: config
            - mountPath: /scripts
              name: scripts
        - name: copy-from-s3
          command: ["/scripts/backup"]
          args: ["copy-from-s3"]
          image: peakcom/s5cmd
          volumeMounts:
            - mountPath: /work-space
              name: work-space
            - mountPath: /config
              name: config
            - mountPath: /scripts
              name: scripts

            - mountPath: /root/.aws/config
              name: aws-config
              subPath: config
            - mountPath: /root/.aws/credentials
              name: aws-credentials
              subPath: credentials
        - name: restore-secrets
          command: ["/scripts/backup"]
          args: ["restore-secrets"]
          image: bitnami/kubectl
          volumeMounts:
            - mountPath: /work-space
              name: work-space
            - mountPath: /scripts
              name: scripts
      volumes:
        - name: work-space
          emptyDir: {}
        - name: aws-config
          configMap:
            name: backup-secrets-aws-config
            items:
              - key: config
                path: config
        - name: aws-credentials
          secret:
            secretName: backup-secrets-aws-credentials
            items:
              - key: credentials
                path: credentials
        - name: config
          configMap:
            name: backup-secrets-config
        - name: scripts
          configMap:
            defaultMode: 0755
            name: backup-secrets-scripts