apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cronjob-cleaner
  namespace: monitoring
  labels:
    app: cronjob-cleaner
  # annotations:
  #   sidecar.istio.io/inject: "false"
  #   linkerd.io/inject: disabled
spec:
  schedule: "*/1 * * * *"
  startingDeadlineSeconds: 3600
  concurrencyPolicy: Forbid
  jobTemplate:
    metadata:
      labels:
        app: cronjob-cleaner
      # annotations:
      #   sidecar.istio.io/inject: "false"
      #   linkerd.io/inject: disabled
    spec:
      template:
        metadata:
          labels:
            app: cronjob-cleaner
          # annotations:
          #   sidecar.istio.io/inject: "false"
          #   linkerd.io/inject: disabled
        spec:
          serviceAccountName: cronjob-cleaner
          containers:
            - name: cronjob-cleaner
              image: kevinshelaga/cronjob-cleaner:tag
              env:
                - name: InCusterConfig
                  value: "true"
                - name: "ActiveDeadlineSecond"
                  value: "4200"
                - name: "GetPodLogs"
                  value: "true"
                - name: "LogTail"
                  value: "100"
                - name: "CleanFailedJob"
                  value: "true"
                - name: "DeleteJob"
                  value: "true"
                - name: "DeletePod"
                  value: "true"
              resources:
                limits:
                  cpu: 200m
                  memory: 0.2Gi
                requests:
                  cpu: 100m
                  memory: 0.1Gi
              terminationMessagePath: "/dev/termination-log"
              terminationMessagePolicy: File
              imagePullPolicy: IfNotPresent
              securityContext:
                privileged: false
          restartPolicy: OnFailure
          terminationGracePeriodSeconds: 30
