Container Orchestration
medium
Pregunta de Container Orchestration #019e3a4f
Enunciado de la Pregunta
Container Orchestration
#kubernetes
#cronjob
#workload
#scheduling
Medio
What is the Kubernetes object used for running a recurring workload?
A
Job
B
Batch
C
DaemonSet
D
CronJob
Correcto
Explicación Oficial / Explicaciones de la Comunidad
The correct answer is CronJob. In Kubernetes, a CronJob is used to run recurring workloads on a time-based schedule, similar to a cron job in Unix-like systems. It creates Jobs on a repeating schedule defined by a cron expression.
How it Works
A CronJob object is defined with a schedule (e.g., */5 * * * * for every 5 minutes) and a job template. The Kubernetes control plane evaluates the schedule and creates a new Job object each time the schedule triggers. The Job then runs one or more Pods to completion. CronJobs are ideal for periodic tasks like backups, report generation, or cleanup operations.
Why the Correct Answer is Right
- CronJob: Directly designed for recurring tasks. It leverages the cron format for scheduling and automatically manages Job creation and history.
Why the Incorrect Answers are Wrong
- Job: A Job creates one or more Pods and ensures they run to completion. It is intended for one-time or batch tasks, not recurring execution. To run a Job repeatedly, you would need an external scheduler or a CronJob.
- Batch: This is not a standard Kubernetes object. The term "batch" might refer to batch processing, but Kubernetes does not have a native
Batchresource. Jobs and CronJobs are the batch-related objects. - DaemonSet: Ensures that a copy of a Pod runs on all (or some) nodes. It is used for long-running daemon processes like log collectors or monitoring agents, not for scheduled, recurring tasks.