apiVersion: batch/v1
kind: Job
metadata:
  name: konga-prepare-job
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      containers:
      - name: konga-prepare-job
        image: pantsel/konga:0.14.9
        command: ["sh", "-c", "node ./bin/konga.js prepare --adapter postgres --uri postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_DATABASE"]
        env:
          - name: NODE_ENV
            value: production
          - name: DB_ADAPTER
            value: postgres
          - name: DB_HOST
            valueFrom:
              configMapKeyRef:
                name: pgconnection
                key: postgres_private_ip
          - name: DB_PORT
            value: "5432"
          - name: DB_POOLSIZE
            value: "2"
          - name: DB_DATABASE
            value: konga
          - name: DB_USER
            valueFrom:
              secretKeyRef:
                name: pgadmin-console
                key: user
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: pgadmin-console
                key: password
      restartPolicy: Never
  backoffLimit: 4