apiVersion: batch/v1
kind: CronJob
metadata:
  name: clear-mylar3-cache
  namespace: download
spec:
  # 4am every day
  schedule: "0 4 * * *"
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 2
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: clear-mylar3-cache
            image: frolvlad/alpine-bash
            imagePullPolicy: IfNotPresent
            command:
            - /bin/bash
            - -c
            - find /config/mylar/cache/* -maxdepth 1 ! -name "*.jpg" -delete
            volumeMounts:
            - name: mylar3-config
              mountPath: /config
            securityContext:
              runAsNonRoot: true
              runAsUser: 1000
          restartPolicy: OnFailure
          volumes:
          - name: mylar3-config
            hostPath:
              path: /mnt/MainPool/Kubernetes/mylar3