# services/cassandra/retention-cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: cassandra-retention
  namespace: cassandra
  labels:
    app: cassandra-retention
spec:
  suspend: true
  schedule: "17 4 * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            app: cassandra-retention
        spec:
          restartPolicy: Never
          serviceAccountName: cassandra-retention
          automountServiceAccountToken: false
          priorityClassName: cassandra-core
          nodeSelector:
            cassandra.bstein.dev/node-pool: oceanus
            kubernetes.io/arch: amd64
          tolerations:
            - key: veles.bstein.dev/simulation
              operator: Equal
              value: "true"
              effect: NoSchedule
          securityContext:
            fsGroup: 10001
            fsGroupChangePolicy: OnRootMismatch
            seccompProfile:
              type: RuntimeDefault
          containers:
            - name: retention
              image: registry.bstein.dev/cassandra/cassandra-backend:0.9.37 # {"$imagepolicy": "cassandra:cassandra-backend"}
              imagePullPolicy: IfNotPresent
              command: ["cassandra-hygiene"]
              args: ["--prune-artifacts"]
              envFrom:
                - configMapRef:
                    name: cassandra-config
              volumeMounts:
                - name: artifacts
                  mountPath: /data/cassandra-artifacts
              resources:
                requests:
                  cpu: 50m
                  memory: 128Mi
                limits:
                  cpu: 250m
                  memory: 512Mi
              securityContext:
                runAsNonRoot: true
                runAsUser: 10001
                runAsGroup: 10001
                allowPrivilegeEscalation: false
                capabilities:
                  drop: ["ALL"]
          volumes:
            - name: artifacts
              persistentVolumeClaim:
                claimName: cassandra-artifacts
