Check in from a Kubernetes CronJob
Monitor a Kubernetes CronJob with BotPings. Keep the check-in URL in a Secret and report success or failure when your scheduled container exits.
Kubernetes · 5 min · Servers and scripts
Before you start
Create a check-in in BotPings with a deadline after the job normally finishes. Use a namespace you can administer. Your job image needs a shell and curl.
Steps
Store the private URL in a Secret
Save only the check-in URL to a protected file named check-in-url in your working directory. Use the namespace that will run the CronJob.
kubectl create secret generic botpings-check-in --from-file=BOTPINGS_CHECK_IN_URL=./check-in-urlWrap the workload
Save this as backup-cronjob.yaml. Replace the image and /app/backup.sh with your own job. Match schedule and timeZone to your check-in settings.
apiVersion: batch/v1
kind: CronJob
metadata:
name: monitored-backup
spec:
schedule: "0 3 * * *"
timeZone: America/Chicago
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: backup
image: example.com/backup:1
imagePullPolicy: IfNotPresent
env:
- name: BOTPINGS_CHECK_IN_URL
valueFrom:
secretKeyRef:
name: botpings-check-in
key: BOTPINGS_CHECK_IN_URL
command: ["/bin/sh", "-ec"]
args:
- |
if /app/backup.sh; then
curl -fsS --max-time 15 "$BOTPINGS_CHECK_IN_URL"
else
status=$?
curl -fsS --max-time 15 "$BOTPINGS_CHECK_IN_URL/fail" || true
exit "$status"
fiApply the CronJob
Confirm the current kubectl context and namespace before applying the manifest.
kubectl apply -f backup-cronjob.yamlTest it
Run one disposable job from the CronJob. After a successful exit, check Last check-in in BotPings. Test a failing command on a separate demo run and confirm the failure alert.
kubectl create job --from=cronjob/monitored-backup monitored-backup-test
kubectl wait --for=condition=complete job/monitored-backup-test --timeout=120s
If it doesn’t work
- The Pod did not start. Inspect Job and Pod events. Confirm the Secret exists in the same namespace and the image can be pulled.
- The backup succeeded but the check-in didn’t arrive. Verify egress from the Pod and the check-in URL.
- The job runs at the wrong time. Compare the CronJob’s timeZone and schedule with the check-in deadline.
Related guides
Checked with a local Kubernetes CronJob and BotPings 1.0, November 2026.