# Copyright (c) 2020 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: curator
spec:
  schedule: "15 0 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: curator-add-task
          initContainers:
            - name: curator-add-task
              image: quay.io/sighup/kubectl
              command:
                - /bin/sh
                - -c
                - "kubectl create job curator-add-task-$(date +%s) --from=cronjob/snapshot-configurator"
              envFrom:
                - configMapRef:
                    name: es-backup-env
                - secretRef:
                    name: es-backup-env
          containers:
            - name: curator
              image: quay.io/sighup/curator
              command: ["curator"]
              args: ["--config", "/config/config.yml", "/config/action.yml"]
              envFrom:
                - configMapRef:
                    name: es-backup-env
                - secretRef:
                    name: es-backup-env
              resources:
                requests:
                  cpu: 100m
                  memory: 500Mi
                limits:
                  cpu: 300m
                  memory: 800Mi
              volumeMounts:
                - name: curator-config
                  mountPath: /config
          restartPolicy: OnFailure
          volumes:
            - name: curator-config
              configMap:
                name: curator
