---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: cloudflare-ddns
  namespace: networking
spec:
  schedule: "*/5 * * * *"
  concurrencyPolicy: "Forbid"
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 5
  jobTemplate:
    spec:
      backoffLimit: 3
      ttlSecondsAfterFinished: 300
      template:
        spec:
          automountServiceAccountToken: false
          restartPolicy: Never
          containers:
            - name: cloudflare-ddns
              image: ghcr.io/k8s-at-home/kubectl:v1.24.1
              envFrom:
                - secretRef:
                    name: cloudflare-ddns-home
              command:
                - "/bin/bash"
                - "/app/cloudflare-ddns.sh"
              volumeMounts:
                - name: cloudflare-ddns-home
                  mountPath: /app/cloudflare-ddns.sh
                  subPath: cloudflare-ddns.sh
                  readOnly: true
          volumes:
            - name: cloudflare-ddns-home
              projected:
                defaultMode: 0775
                sources:
                  - configMap:
                      name: cloudflare-ddns-home
                      items:
                        - key: cloudflare-ddns.sh
                          path: cloudflare-ddns.sh
