apiVersion: batch/v1
kind: Job
metadata:
  labels:
    application: spilo-logical-backup
    job-name: dump
  name: dump
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  selector:
    matchLabels:
      job-name: dump
  template:
    metadata:
      creationTimestamp: null
      labels:
        application: spilo-logical-backup
        job-name: dump
    spec:
      affinity:
        podAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  application: spilo-logical-backup
                  version: pg-${PG_DOMAIN}
              topologyKey: kubernetes.io/hostname
            weight: 1
      containers:
      - env:
        - name: LOGICAL_BACKUP_PROVIDER
          value: minio
        - name: SCOPE
          value: pg-${PG_DOMAIN}
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        - name: CLUSTER_NAME_LABEL
          value: cluster-name
        - name: LOGICAL_BACKUP_S3_BUCKET
          value: ${NS}-dumps
        - name: LOGICAL_BACKUP_S3_ENDPOINT
          value: https://minio.k7.indie.host
        - name: LOGICAL_BACKUP_S3_BUCKET_SCOPE_SUFFIX
          value: /nextcloud
        - name: LOGICAL_BACKUP_S3_REGION
          value: default
        - name: LOGICAL_BACKUP_S3_SSE
        - name: PG_VERSION
          value: "12"
        - name: PGPORT
          value: "5432"
        - name: PGUSER
          value: postgres
        - name: PGDATABASE
          value: postgres
        - name: PGSSLMODE
          value: require
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              key: password
              name: postgres.pg-${PG_DOMAIN}.credentials
        - name: AWS_S3_FORCE_PATH_STYLE
          value: "true"
        envFrom:
        - secretRef:
            name: ${NS}-dumps
        image: registry.opensource.zalan.do/acid/logical-backup:v1.6.2
        imagePullPolicy: IfNotPresent
        name: logical-backup
        ports:
        - containerPort: 8008
          protocol: TCP
        - containerPort: 5432
          protocol: TCP
        - containerPort: 8080
          protocol: TCP
        resources: {}
        securityContext:
          privileged: false
          readOnlyRootFilesystem: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: zalando-postgres
      serviceAccountName: zalando-postgres
      terminationGracePeriodSeconds: 30
