apiVersion: batch/v1
kind: Job
metadata:
  name: pg-dump-backup
spec:
  parallelism: 1
  completions: 1
  template:
    metadata:
      name: pg-dump-backup
    spec:
      containers:
      - env:
         - name: DATABASE_URL
           valueFrom:
             secretKeyRef:
               key: database-url
               name: db
         - name: DATABASE_NAME
           value: db
         - name: DATABASE_BACKUP_PATH
           value: '/var/backups'
         - name: RETENTION_DAYS
           value: '30'
        name: pg-dump-backup
        image: 'pg-dump-backup'
        resources:
          limits:
            cpu: 250m
            memory: 256Mi
          requests:
            cpu: 250m
            memory: 256Mi
        volumeMounts:
         - mountPath: /var/backups
           name: db-backups
      restartPolicy: Never
      volumes:
        - name: db-backups
          persistentVolumeClaim:
            claimName: db-backups
