---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: &app vector-geoipupdate
  namespace: monitoring
spec:
  schedule: "0 0 * * 0"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 5
  jobTemplate:
    spec:
      backoffLimit: 3
      ttlSecondsAfterFinished: 300
      template:
        spec:
          automountServiceAccountToken: false
          restartPolicy: Never
          containers:
            - name: *app
              image: docker.io/maxmindinc/geoipupdate:v4.9
              imagePullPolicy: IfNotPresent
              lifecycle:
                preStop:
                  exec:
                    command:
                      - /bin/sh
                      - -c
                      - rm -rf /usr/share/GeoIP/.geoipupdate.lock
              env:
                - name: GEOIPUPDATE_EDITION_IDS
                  value: GeoLite2-City
                - name: GEOIPUPDATE_FREQUENCY
                  value: "0"
                - name: GEOIPUPDATE_VERBOSE
                  value: "true"
              envFrom:
                - secretRef:
                    name: *app
              volumeMounts:
                - name: *app
                  mountPath: /usr/share/GeoIP
          volumes:
            - name: *app
              persistentVolumeClaim:
                claimName: vector-geoipupdate-config-v1
