apiVersion: apps/v1
kind: Deployment

metadata:
  namespace: singouins-dev
  name: sep-backend-backup
  labels:
    tier: sep-backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backup
      tier: sep-backend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: backup
        tier: sep-backend
    spec:
      restartPolicy: Always

      containers:
      - name: sep-backend-backup
        image: lordslair/easydbbackup:latest
        imagePullPolicy: Always
        resources:
          limits:
            memory: 64Mi
            cpu: 100m
          requests:
            memory: 16Mi
            cpu: 10m
        env:
          - name: RCLONE_CONFIG_PCS_TYPE
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-type
          - name: RCLONE_CONFIG_PCS_ENV_AUTH
            valueFrom:
              secretKeyRef:
                name: sep-backend-backup-secret
                key: pcs-env-auth
          - name: RCLONE_CONFIG_PCS_AUTH_VERSION
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-auth-version
          - name: RCLONE_CONFIG_PCS_TENANT_DOMAIN
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-tenant-domain
          - name: RCLONE_CONFIG_PCS_DOMAIN
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-domain
          - name: RCLONE_CONFIG_PCS_AUTH
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-auth
          - name: RCLONE_CONFIG_PCS_TENANT
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-tenant
          - name: RCLONE_CONFIG_PCS_USER
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-private-user
          - name: RCLONE_CONFIG_PCS_KEY
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-private-key
          - name: RCLONE_CONFIG_PCS_REGION
            valueFrom:
              secretKeyRef:
                name: sep-backend-pcs-secret
                key: pcs-region
          - name: RCLONE_CONFIG_PCS_DIR
            valueFrom:
              secretKeyRef:
                name: sep-backend-backup-secret
                key: pcs-dir

          # MYSQL specifics
          - name: MYSQL_DUMP
            valueFrom:
              secretKeyRef:
                name: sep-backend-backup-secret
                key: mysql-dump
          - name: MYSQL_DB_LIST
            valueFrom:
              secretKeyRef:
                name: sep-backend-backup-secret
                key: mysql-dblist
          - name: MYSQL_DB_HOST
            valueFrom:
              secretKeyRef:
                name: sep-backend-mariadb-secret
                key: mariadb-host
          - name: MYSQL_DB_PORT
            valueFrom:
              secretKeyRef:
                name: sep-backend-mariadb-secret
                key: mariadb-port
          - name: MYSQL_DB_PASS
            valueFrom:
              secretKeyRef:
                name: sep-backend-mariadb-secret
                key: mariadb-pass
          - name: MYSQL_DB_USER
            valueFrom:
              secretKeyRef:
                name: sep-backend-mariadb-secret
                key: mariadb-user

          # REDIS specifics
          - name: REDIS_DUMP
            valueFrom:
              secretKeyRef:
                name: sep-backend-backup-secret
                key: redis-dump
          - name: REDIS_DB_HOST
            valueFrom:
              secretKeyRef:
                name: sep-backend-redis-secret
                key: redis-host
          - name: REDIS_DB_PORT
            valueFrom:
              secretKeyRef:
                name: sep-backend-redis-secret
                key: redis-port
