apiVersion: batch/v1
kind: Job
metadata:
  name: psql-connect5
spec:
  backoffLimit: 3
  template:
    spec:
      restartPolicy: "OnFailure"
      containers:
        - name: psql
          image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-14.1-0
          command:
            - psql
            - -c
            - "select version();"
          env:
          - name: PGHOST
            valueFrom: { secretKeyRef: { name: password-change-pguser-rhino, key: host } }
          - name: PGPORT
            valueFrom: { secretKeyRef: { name: password-change-pguser-rhino, key: port } }
          - name: PGDATABASE
            valueFrom: { secretKeyRef: { name: password-change-pguser-rhino, key: dbname } }
          - name: PGUSER
            valueFrom: { secretKeyRef: { name: password-change-pguser-rhino, key: user } }
          # Hardcoding the password here to be equal to what we changed the password to in 
          # ./08-secret.yaml
          # The ./08-errors.yaml checks that the secret is not in the state that we set it to
          # in the ./08-secret.yaml file, i.e., the secret has been reconciled by PGO
          - name: PGPASSWORD
            value: datalake
          
          # Do not wait indefinitely.
          - { name: PGCONNECT_TIMEOUT, value: '5' }
