# Copyright (c) 2021 SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: fip-results-controller
  labels:
    app.kubernetes.io/created-by: healthcheck-controller
    kfip.sighup.io/group: IntelligentPlatform
    kfip.sighup.io/target: ResultController
    kfip.sighup.io/check: prune
spec:
  schedule: "*/1 * * * *"
  startingDeadlineSeconds: 10 # if a job hasn't starting in this many seconds, skip
  concurrencyPolicy: Forbid # either allow|forbid|replace
  successfulJobsHistoryLimit: 10 # how many completed jobs should be
  jobTemplate:
    metadata:
      labels:
        app.kubernetes.io/created-by: healthcheck-controller
        kfip.sighup.io/group: IntelligentPlatform
        kfip.sighup.io/target: ResultController
        kfip.sighup.io/check: prune
    spec:
      template:
        metadata:
          labels:
            app.kubernetes.io/created-by: healthcheck-controller
            kfip.sighup.io/group: IntelligentPlatform
            kfip.sighup.io/target: ResultController
            kfip.sighup.io/check: prune
        spec:
          serviceAccountName: fip-results-controller
          containers:
          - name: fip-results-controller
            image: registry.sighup.io/poc/fip-results-controller:unstable
            args: ["prune", "--log-level", "$(RC_LOG_LEVEL)", "--keep", "$(RC_KEEP)"]
            imagePullPolicy: IfNotPresent
            envFrom:
              - configMapRef:
                  name: rc-envs
          restartPolicy: OnFailure
