apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: airflow-logrotate
  namespace: airflow
spec:
  schedule: "@daily"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: logrotate
            image: busybox
            args:
            - /bin/sh
            - -c
            - find /logs  -type f -mtime +7 -size +10b -exec echo {} \; -exec truncate -s 0 {} \;
            volumeMounts:
            - mountPath: /logs
              name: logs-data
          volumes:
            - name: logs-data
              persistentVolumeClaim:
                claimName: airflow-logs
          restartPolicy: Never
