---
apiVersion: batch/v1
kind: Job
metadata:
  name: mongodb-cleanup
spec:
  template:
    spec:
      containers:
      - name: mongodb-cleanup
        image: alpine
        command:
        - /bin/sh
        - -c
        - echo "Before cleanup" && ls -l /data/db/ && rm -rf /data/db/* && echo "After cleanup" && ls -l /data/db/
        volumeMounts:
          - mountPath: "/data/db"
            name: mongodata-pv-storage
      restartPolicy: Never
      volumes:
        - name: mongodata-pv-storage
          persistentVolumeClaim:
            claimName: mongodata-pv-claim