apiVersion: v1
kind: Pod
metadata:
  name: kotsadm-migrations
  labels:
    kots.io/kotsadm: "true"
    kots.io/backup: velero
spec:
  securityContext:
    runAsUser: 1001
    fsGroup: 1001
  restartPolicy: OnFailure
  volumes:
    - name: migrations
      emptyDir:
        medium: Memory

  initContainers:
  - name: migrations-plan
    image: kotsadm/kotsadm-migrations:v1.22.4
    args: ["plan"]
    volumeMounts:
    - name: migrations
      mountPath: /migrations
    env:
    - name: SCHEMAHERO_DRIVER
      value: postgres
    - name: SCHEMAHERO_SPEC_FILE
      value: /tables
    - name: SCHEMAHERO_URI
      valueFrom:
        secretKeyRef:
          name: kotsadm-postgres
          key: uri
    - name: SCHEMAHERO_OUT
      value: /migrations/plan.yaml              
    resources:
      limits:
        cpu: 100m
        memory: 100Mi
      requests:
        cpu: 50m
        memory: 50Mi

  containers:
  - name: kotsadm-migrations
    image: kotsadm/kotsadm-migrations:v1.22.4
    args: ["apply"]
    volumeMounts:
      - name: migrations
        mountPath: /migrations
    env:
    - name: SCHEMAHERO_DRIVER
      value: postgres
    - name: SCHEMAHERO_DDL
      value: /migrations/plan.yaml
    - name: SCHEMAHERO_URI
      valueFrom:
        secretKeyRef:
          name: kotsadm-postgres
          key: uri
    resources:
      limits:
        cpu: 100m
        memory: 100Mi
      requests:
        cpu: 50m
        memory: 50Mi
