What is the difference between a Kubernetes Job and a CronJob?

Medium Topic: Kubernetes June 17, 2026

Kubernetes Jobs and CronJobs are workload resources for running tasks to completion rather than running continuously like Deployments.

Kubernetes Job

A Job creates one or more pods and ensures a specified number of them successfully terminate. Once the required completions are reached, the Job is complete.

Use Cases

  • Database migrations
  • Batch data processing
  • One-time setup tasks
  • Report generation

Example Job

apiVersion: batch/v1
kind: Job
metadata:
  name: db-migration
spec:
  completions: 1
  parallelism: 1
  backoffLimit: 3
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: migrate
        image: myapp:latest
        command: ["python", "manage.py", "migrate"]

Job Patterns

  • Non-parallel: Single pod runs to completion
  • Parallel with fixed count: Multiple pods, each does a portion
  • Parallel with work queue: Pods process items from a queue

CronJob

A CronJob creates Jobs on a repeating schedule using standard Unix cron syntax.

Use Cases

  • Nightly database backups
  • Hourly report generation
  • Periodic cleanup tasks
  • Scheduled ETL pipelines

Example CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-backup
spec:
  schedule: "0 2 * * *"  # 2 AM every day
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: backup
            image: backup-tool:latest
            command: ["/backup.sh"]

Key Differences

FeatureJobCronJob
TriggerManual/one-timeScheduled (cron)
RecurrenceRuns onceRepeats on schedule
Use caseAd-hoc tasksRecurring tasks
CreatesPods directlyJobs (which create pods)
← Previous What are Init Containers in Kubernetes and what... Next → What is etcd and what role does it...

Practice Similar Questions

Back to Kubernetes Topics