apiVersion: v1
kind: PersistentVolume
metadata:
  name: midjourney-sort-and-upload
spec:
  capacity:
    storage: 10Ti
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Kubernetes/volumes/static/midjourney-sort-and-upload
    server: 10.42.42.10
  claimRef:
    name: midjourney-sort-and-upload
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: midjourney-sort-and-upload
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Ti
status: {}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: midjourney-sort-and-upload-workdir
spec:
  capacity:
    storage: 10Ti
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain # Keep 4eva
  storageClassName: default
  mountOptions:
    - hard
    - nfsvers=3
  nfs:
    path: /mnt/DroboFS/Shares/Public/midjourney
    server: 10.42.42.10
  claimRef:
    name: midjourney-sort-and-upload-workdir
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: midjourney-sort-and-upload-workdir
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Ti
status: {}
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: cron-midjourney-sort-and-upload
spec:
  schedule: "0 */1 * * *"
  concurrencyPolicy: Forbid
  # Start up to 30 minutes late
  startingDeadlineSeconds: 1800
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 1700
      backoffLimit: 4
      template:
        spec:
          containers:
          - name: cron-midjourney-sort-and-upload
            image: fdamstra/midjourney-sort-and-upload
#            envFrom:
#              - secretRef:
#                  name: midjourney-sort-and-upload
            volumeMounts:
            - name: midjourney-sort-and-upload
              mountPath: /scratch/
            - name: midjourney-sort-and-upload-workdir
              mountPath: /midjourney/
#            - name: gdrive-token
#              mountPath: /root/.gdrive/
          dnsPolicy: "None"
          dnsConfig:
            nameservers:
              - 10.42.42.239
              - 10.42.42.1
            searches:
              - default.svc.cluster.local
              - svc.cluster.local
              - cluster.local
            options:
              - name: ndots
                value: "2"
              - name: edns0
              - name: trust-ad
          restartPolicy: Never
          volumes:
          - name: midjourney-sort-and-upload
            persistentVolumeClaim:
              claimName: midjourney-sort-and-upload
          - name: midjourney-sort-and-upload-workdir
            persistentVolumeClaim:
              claimName: midjourney-sort-and-upload-workdir
#          - name: gdrive-token
#            secret:
#              secretName: gdrive-token
#              items:
#                - key: TOKEN
#                  path: token_v2.json
