apiVersion: batch/v1
kind: Job
metadata:
  name: seed-reading-contest-api-job
spec:
  template:
    metadata:
      name: "seed-reading-contest-api-job-pod"
    spec:
      restartPolicy: Never
      containers:
      - name: seed-reading-contest-api
        imagePullPolicy: IfNotPresent
        image: postgres:13
        command: [ "bin/sh", "-c", "psql -a -f /seed.sql" ]
        volumeMounts:
          - name: seed-sql
            mountPath: /seed.sql
            subPath: seed.sql
        envFrom:
          - secretRef:
              name: tadoku-user.tadoku-reading-contest-api-db.credentials.postgresql.acid.zalan.do
        env:
        - name: PGUSER
          valueFrom:
            secretKeyRef:
              name: tadoku-user.tadoku-reading-contest-api-db.credentials.postgresql.acid.zalan.do
              key: username
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              name: tadoku-user.tadoku-reading-contest-api-db.credentials.postgresql.acid.zalan.do
              key: password
        - name: PGHOST
          value: tadoku-reading-contest-api-db
        - name: PGDATABASE
          value: tadoku
      volumes:
        - name: seed-sql
          configMap:
            name: seed-sql-reading-contest-api
