apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: timescale-prune
  labels: &labels
    k8s-app: timescale
    "{{ secrets.dns.base }}/timescale-name": "{{ item.name }}"
    "{{ secrets.dns.base }}/timescale-role": "prune"
spec:
  schedule: "0 0 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          labels: *labels
        spec:
          restartPolicy: Never
          containers:
            - name: prune-exec
              image: apextoaster/kube:master
              args:
                - /bin/bash
                - -c
                - /scripts/timescale-prune.sh metric_samples "{{ secrets.dns.slug }}" "{{ secrets.dns.base }}" "30 days"
              volumeMounts:
                - name: cluster-scripts
                  mountPath: /scripts

          serviceAccountName: timescale-prune
          volumes:
            # cluster scripts dir
            - name: cluster-scripts
              configMap:
                name: cluster-scripts
                defaultMode: 0755
