Skip to content

Monitoring Kubernetes CronJobs

Kubernetes CronJobs are scheduled workloads that run in pods. When a CronJob fails, Kubernetes may retry or simply mark it failed—but you won’t know unless you’re watching the cluster.

Pass your API key as a Kubernetes secret:

env:
- name: PAKYAS_API_KEY
valueFrom:
secretKeyRef:
name: pakyas-credentials
key: api-key

Create the secret:

Terminal window
kubectl create secret generic pakyas-credentials --from-literal=api-key=pk_live_xxxxx

See Environment Variables for all options.

  • CronJobs run on a schedule in Kubernetes
  • Missing a run affects your application
  • You need alerts outside the cluster

Update your CronJob spec to wrap the command with pakyas:

spec:
containers:
- name: job
image: your-image
command: ["pakyas", "monitor", "k8s-cronjob", "--", "/app/run.sh"]

Pakyas sends pings from inside the pod, so you get alerts even if the cluster itself has issues.

apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-job
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: job
image: your-image
command: ["pakyas", "monitor", "k8s-cronjob", "--", "/app/run.sh"]
restartPolicy: OnFailure
  • Job container exits non-zero
  • Job runs longer than expected
  • Job never runs (missed schedule)