apiVersion: batch/v1
kind: Job
metadata:
  name: flask-init-db
spec:
  backoffLimit: 5
  template:
    spec:
      restartPolicy: Never
      containers:
        - name: flask
          image: kubernetes-flask:v1
          command: ['flask', 'db', 'import-fixtures']
          env:
            - name: FLASK_DATABASE_NAME
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: db

            - name: FLASK_DATABASE_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: user

            - name: FLASK_DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: password

            - name: FLASK_DATABASE_HOST
              value: postgres-service
