Skip to content
HookPulse

Monitor Kubernetes CronJobs with HookPulse check-ins

The CronJob container sends its exit status to HookPulse. The check-in URL stays in a Secret.

Updated

1Create the monitor

Add a routine named k8s-backup and set how often the job runs. Its page shows the check-in URL: use it in place of https://hookpulse.net/in/YOUR_ID.

2Store the check-in URL in a Secret

Use your check-in URL in place of the example.

kubectl create secret generic hookpulse --from-literal=url="https://hookpulse.net/in/YOUR_ID"

3End the container command with the check-in

The image needs curl. With backoffLimit 0, a failure is reported once.

apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-backup
spec:
  schedule: "0 3 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      backoffLimit: 0
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: backup
              image: my-backup:1.0
              env:
                - name: HOOKPULSE_URL
                  valueFrom:
                    secretKeyRef: { name: hookpulse, key: url }
              command: ["/bin/sh", "-c"]
              args: ["backup.sh; curl -fsS -m 10 --retry 3 \"$HOOKPULSE_URL/$?\""]

4Run it once

Run kubectl create job --from=cronjob/nightly-backup backup-test. The routine shows the first check-in. From then on, a missed or failed run sends the alert.