---
apiVersion: batch/v1
kind: CronJob
metadata:
  namespace: network
  name: cloudflare-ddns
spec:
  schedule: "0/30 * * * *"
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  concurrencyPolicy: Forbid
  jobTemplate:
    metadata:
      annotations:
        botkube.io/disable: "true"
    spec:
      template:
        metadata:
          annotations:
            botkube.io/disable: "true"
        spec:
          restartPolicy: Never
          containers:
            - name: cloudflare-ddns
              image: ghcr.io/k8s-at-home/kubectl:v1.23.4
              imagePullPolicy: IfNotPresent
              env:
                - name: TZ
                  value: Europe/Amsterdam
              workingDir: /scripts
              command:
                - "/bin/bash"
                - "/scripts/cloudflare-ddns.sh"
              volumeMounts:
                - name: cloudflare-ddns
                  mountPath: /scripts/cloudflare-ddns.sh
                  subPath: cloudflare-ddns.sh
                  readOnly: true
                - name: data
                  mountPath: /scripts/ddns_data.json
                  subPath: ddns_data.json
                  readOnly: true
          volumes:
            - name: cloudflare-ddns
              projected:
                defaultMode: 0775
                sources:
                  - configMap:
                      name: cloudflare-ddns
                      items:
                        - key: cloudflare-ddns.sh
                          path: cloudflare-ddns.sh
            - name: data
              secret:
                secretName: cloudflare-ddns-data
