Back to articles
Heartbeat monitoring for Kubernetes CronJobs
How-ToDevOps

Heartbeat monitoring for Kubernetes CronJobs

via Dev.toJoao Thomazinho

Kubernetes CronJobs are great until they quietly fail. Maybe the pod image can't pull, or the job exceeds backoff limits. CronObserver adds a simple heartbeat so you know when jobs don't run on time. Why use heartbeats on CronJobs? CronJobs can be suspended/deleted during deploys. Out-of-resource errors happen silently. Logs rotate quickly; by the time you investigate, the evidence is gone. A single HTTP check-in after the pod completes is enough to warn you. Step 1 – Create an observer Define schedule/grace to match the CronJob. Schedule: */30 * * * * Grace: 5 minutes Alerts: Email + webhook (Slack/Teams) Step 2 – Store the URL in a secret apiVersion : v1 kind : Secret metadata : name : cronobserver-checkin stringData : url : https://cronobserver.com/checkin/<token> Mount the secret as an env var: env : - name : CRONOBSERVER_CHECKIN_URL valueFrom : secretKeyRef : name : cronobserver-checkin key : url Step 3 – Curl after the job completes command : [ " sh" , " -c" , " run-task && curl

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles