apiVersion: batch/v1
kind: CronJob
metadata:
  name: kavita-docker-auto-restart
  namespace: automation
spec:
  schedule: "*/15 * * * *"
  successfulJobsHistoryLimit: 2
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: restart-kavita
              image: docker:27-cli
              command:
                - /bin/sh
                - -c
                - |
                  echo "Restarting Kavita Docker container..."
                  docker restart kavita
                  echo "Kavita restart completed."
              volumeMounts:
                - name: docker-sock
                  mountPath: /var/run/docker.sock
          volumes:
            - name: docker-sock
              hostPath:
                path: /var/run/docker.sock
                type: Socket
