Kubernetes CronJob
Chain the ping after your job’s command inside the CronJob’s container, so it only runs when the job succeeds.
CronJob manifest
apiVersion: batch/v1kind: CronJobmetadata: name: nightly-backupspec: schedule: "0 3 * * *" jobTemplate: spec: template: spec: restartPolicy: Never containers: - name: backup image: your/backup-image:latest command: ["/bin/sh", "-c"] args: - /opt/run-backup.sh && curl -fsS "$DMJR_PING_URL" env: - name: DMJR_PING_URL valueFrom: secretKeyRef: name: dmjr key: ping-url-
The
&&ensures the ping fires only ifrun-backup.shexited successfully. A failed job sends no ping and you get alerted. -
Store the ping URL in a Secret (created from your monitor on the dashboard):
Terminal window kubectl create secret generic dmjr \--from-literal=ping-url="https://didmyjobrun.com/ping/<your-key>" -
Make sure your container image has
curlavailable, or usewget -qO- "$DMJR_PING_URL"instead.
Set the monitor’s period to match schedule and add grace to absorb scheduler delays and pod startup time.