Job

3 min read

Read Jobs and CronJobs: whether a Job succeeded, failed or is running, and when a CronJob last ran, last succeeded and runs next. The functions that look inside a Job’s pods take the pods as a list.

Reference

FunctionDescription
cronJobActiveCountReturns the number of currently active Job runs (length of status.active).
cronJobLastScheduleTimeReturns the last time the CronJob was scheduled (status.lastScheduleTime).
cronJobLastSuccessTimeReturns the last time the CronJob completed successfully (status.lastSuccessfulTime).
cronJobNextScheduleTimeReturns when the CronJob runs next, computed from its spec the way the CronJob controller schedules it: spec.schedule in spec.timeZone (the controller’s zone, UTC here, when unset).
jobActiveReturns true when status.active > 0 — at least one pod is currently running.
jobActivePodNamesReturns the names of the job’s pods that are not done (neither Succeeded nor Failed).
jobFailedReturns true when status.failed > 0 — at least one pod has failed (and not been retried to success).
jobFailedPodNamesReturns the names of the job’s pods that failed.
jobFirstExitCodeReturns the exit code of the first terminated container among the job’s pods; -1 when none has terminated yet.
jobSucceededReturns true when status.succeeded > 0 — at least one pod has completed successfully.
jobSucceededPodNamesReturns the names of the job’s pods that succeeded.

Functions

cronJobActiveCount

cronJobActiveCount returns the number of currently active Job runs (length of status.active).

{{ cronJobActiveCount .cronjob }}  → 1

cronJobLastScheduleTime

cronJobLastScheduleTime returns the last time the CronJob was scheduled (status.lastScheduleTime). Returns "" when not yet scheduled.

{{ cronJobLastScheduleTime .cronjob }}  → "2026-05-19T10:00:00Z"

cronJobLastSuccessTime

cronJobLastSuccessTime returns the last time the CronJob completed successfully (status.lastSuccessfulTime). Returns "" when it has never succeeded.

{{ cronJobLastSuccessTime .cronjob }}  → "2026-05-19T10:00:00Z"

cronJobNextScheduleTime

cronJobNextScheduleTime returns when the CronJob runs next, computed from its spec the way the CronJob controller schedules it: spec.schedule in spec.timeZone (the controller’s zone, UTC here, when unset). "" when the CronJob is suspended or has no schedule; an error when the schedule or time zone does not parse.

{{ cronJobNextScheduleTime .cronjob }}  → "2026-05-19T11:00:00Z"

See also: nextCron, cronJobLastScheduleTime

jobActive

jobActive returns true when status.active > 0 — at least one pod is currently running.

{{ jobActive .job }}  → false

jobActivePodNames

jobActivePodNames returns the names of the job’s pods that are not done (neither Succeeded nor Failed).

{{ jobActivePodNames .jobPods }}  → [migrate-r2d5m]

jobFailed

jobFailed returns true when status.failed > 0 — at least one pod has failed (and not been retried to success).

{{ jobFailed .job }}  → false

jobFailedPodNames

jobFailedPodNames returns the names of the job’s pods that failed.

{{ jobFailedPodNames .jobPods }}  → [migrate-x7k2p]

jobFirstExitCode

jobFirstExitCode returns the exit code of the first terminated container among the job’s pods; -1 when none has terminated yet.

{{ jobFirstExitCode .jobPods }}  → 1

jobSucceeded

jobSucceeded returns true when status.succeeded > 0 — at least one pod has completed successfully.

{{ jobSucceeded .job }}  → true

jobSucceededPodNames

jobSucceededPodNames returns the names of the job’s pods that succeeded.

{{ jobSucceededPodNames .jobPods }}  → [migrate-q9w4z]