apiVersion: batch/v1
kind: Job
metadata:
  name: home-assistant-db-init
spec:
  template:
    spec:
      containers:
        - image: registry.homelab.dsb.dev/library/postgres:13.2
          name: createdb
          command:
            - createdb
          env:
            - name: PGHOST
              value: postgres.storage.svc.cluster.local
            - name: PGDATABASE
              value: home_assistant
            - name: PGUSER
              valueFrom:
                secretKeyRef:
                  key: postgres.user
                  name: postgres
            - name: PGPASSWORD
              valueFrom:
                secretKeyRef:
                  key: postgres.password
                  name: postgres
      restartPolicy: Never
  backoffLimit: 0
