apiVersion: batch/v1
kind: Job
metadata:
  name: migration
  namespace: $K8S_NAMESPACE
spec:
  ttlSecondsAfterFinished: 100
  backoffLimit: 2
  template:
    spec:
      containers:
      - name: migration
        image: $CONTAINER_IMAGE
        command: [
          "/bin/sh", "-c"
        ]
        args:
          - |
              /opt/atat/atst/.venv/bin/python \
              /opt/atat/atst/.venv/bin/alembic \
              upgrade head \
              && \
              /opt/atat/atst/.venv/bin/python \
              /opt/atat/atst/script/seed_roles.py
        envFrom:
        - configMapRef:
            name: atst-envvars
        - configMapRef:
            name: atst-worker-envvars
        volumeMounts:
          - name: atst-config
            mountPath: "/opt/atat/atst/atst-overrides.ini"
            subPath: atst-overrides.ini
          - name: pgsslrootcert
            mountPath: "/opt/atat/atst/ssl/pgsslrootcert.crt"
            subPath: pgsslrootcert.crt
      volumes:
        - name: atst-config
          secret:
            secretName: atst-config-ini
            items:
            - key: override.ini
              path: atst-overrides.ini
              mode: 0644
        - name: pgsslrootcert
          configMap:
            name: pgsslrootcert
            items:
            - key: cert
              path: pgsslrootcert.crt
              mode: 0666
      restartPolicy: Never
