apiVersion: batch/v1
kind: Job
metadata:
  generateName: mongodb-restore-job-${MONGODB_DATABASE_NAME}-
spec:
  template:
    spec:
      restartPolicy: Never
      imagePullSecrets:
        - name: registry.internal.aleemhaji.com
      containers:
        - name: mongodb-restore
          image: registry.internal.aleemhaji.com/mongo:3.7
          command:
            - sh
            - -xec
            - mongorestore --host ${MONGODB_HOST} --drop --db ${MONGODB_DATABASE_NAME} /restore/${MONGODB_DATABASE_NAME}
          env:
            - name: MONGODB_HOST
              value: mongodb
          volumeMounts:
            - name: mongodb-restore-storage
              mountPath: /restore
      volumes:
        - name: mongodb-restore-storage
          nfs:
            server: 192.168.96.4
            path: /mnt/dump/mongodb-restore
