Kubernetes — alert when a CronJob is suspended
Someone set `spec.suspend: true` on a CronJob (debug or rushed release) and forgot to revert. The daily task does not run, reports are not generated — you only learn when finance asks.
Recipe
#!/usr/bin/env bash
# /etc/cron.d/cj-suspended
# 0 9 * * * root /opt/cj-suspended.sh
CONTEXT=${KUBE_CONTEXT:-prod}
SUSP=$(kubectl --context "$CONTEXT" get cronjobs -A -o json \
| jq -r '[.items[] | select(.spec.suspend == true) | "\(.metadata.namespace)/\(.metadata.name)"]')
COUNT=$(echo "$SUSP" | jq 'length')
if [ "${COUNT:-0}" -gt 0 ]; then
NAMES=$(echo "$SUSP" | jq -r '.[]' | head -10 | tr '\n' ',')
curl -fsS "$HEARTBEAT_URL" --data-urlencode "cj_suspended=$COUNT,names=$NAMES"
exit 2
fi
echo "OK (no suspended CronJobs)"
Same thing in Enterno.io
Wire to an Enterno heartbeat — a daily report of "what is currently disabled" so nothing falls through the cracks.
Related recipes
Readiness probes pass inside the pod, but no one sees that the LB refused to route traffic to the new deploy.
A CrashLoopBackOff in one namespace — kubectl shows a restart count of 47, but nobody sees it. Want an endpoint that returns high when the counter jumps.
Inside a K8s cluster etcd re-elects the leader every 30 s — kube-apiserver lags, controller-manager can't keep reconciling. Only visible in etcd metrics.