CronJob Resource Fundamentals
You'll learn how to schedule recurring Jobs in Kubernetes using CronJobs, the workload resource for time-based automation.
What is a CronJob?
A CronJob in Kubernetes creates Jobs on a repeating schedule, just like the classic Unix cron utility. Think of it as setting a recurring alarm: instead of running a task once (Job), you want it to execute every hour, every night at midnight, or every Monday morning. CronJobs automate periodic tasks like backups, report generation, cleanup operations, or health checks.
Core Components
A CronJob wraps a Job template with a schedule specification. The schedule uses standard cron syntax:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday)
# │ │ │ │ │
# * * * * *
For example, 0 2 * * * means "run at 2:00 AM every day."
CronJob Structure
A CronJob manifest contains:
schedule: Cron expression defining when to runjobTemplate: The Job specification to create (identical to standalone Job manifests)- Execution policies: Control behavior for missed runs, concurrent executions, and success/failure history
The CronJob controller watches the clock and spawns new Job objects according to your schedule. Each Job then manages its own Pods as you've already learned.
Real-World Analogy
CronJobs are like a calendar reminder app: you define what to do (job template) and when to do it (schedule), and Kubernetes handles triggering it automatically at the right times.
Key Takeaway: CronJobs schedule recurring Jobs using cron syntax and job templates, enabling automated periodic workloads in your cluster.