kind: Job
apiVersion: batch/v1
metadata:
  name: migrate-database
  labels:
    app.kubernetes.io/name: postgres
    app.kubernetes.io/part-of: device-registry
spec:
  backoffLimit: 1000
  completions: 1
  parallelism: 1
  ttlSecondsAfterFinished: 600
  template:
    spec:
      restartPolicy: OnFailure
      containers:
        - name: diesel-migrate
          image: ghcr.io/drogue-iot/database-migration:latest
          imagePullPolicy: Always
          env:
            - name: POSTGRES_DB
              valueFrom:
                configMapKeyRef:
                  name: postgres-config
                  key: databaseName
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-secret
                  key: admin.username
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-secret
                  key: admin.password
            - name: DATABASE_URL
              value: postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@postgres/$(POSTGRES_DB)
