Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsEasy
A developer needs to deploy a batch job in Kubernetes that runs a series of computations and then exits successfully. The job should not automatically restart if it completes its task. Which kind of Kubernetes object is best suited for this one-time, finite task?
- AJob
- BStatefulSet
- CDeployment
- DDaemonSet
Show answer & explanationAnswer & explanation
Correct answer: A. Job
A Kubernetes Job creates one or more Pods and ensures that a specified number of them successfully terminate. Once the specified number of Pods successfully complete their tasks, the Job is considered complete. This makes it ideal for one-time, finite tasks like batch computations.
Why the other options are wrong
- B. A StatefulSet is used for stateful applications, ensuring stable network identities and persistent storage, not for finite jobs.
- C. A Deployment manages stateless applications and is designed for long-running services, not one-time tasks.
- D. A DaemonSet ensures that a copy of a Pod runs on all (or some) nodes in a cluster, typically for cluster-level services, not for one-time tasks.
Kubernetes Job
A Kubernetes object that creates one or more Pods and ensures that a specified number of them successfully terminate, suitable for one-time or batch tasks.
- Runs Pods to completion.
- Designed for batch processing.
- Does not restart completed Pods by default.
Memory trick: Job's job is to run and finish!