Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsEasy

A developer needs to execute a one-off, short-lived task in a Kubernetes cluster, such as a database migration script or a batch processing job. This task should run to completion and then terminate. Which type of Kubernetes workload object is most suitable for this scenario?

  1. ADeployment
  2. BJob
  3. CStatefulSet
  4. DDaemonSet
Show answer & explanation

Correct answer: B. Job

A Kubernetes Job creates one or more Pods and ensures that a specified number of them successfully terminate. Jobs are designed for tasks that run to completion, unlike Deployments which manage ongoing, long-running applications.

Why the other options are wrong

  • A. A Deployment is used for stateless applications that run continuously and need to be scaled and updated.
  • C. A StatefulSet is used for stateful applications, ensuring stable network identifiers and ordered deployment/scaling.
  • D. A DaemonSet ensures that a Pod runs on all (or some) Nodes in a cluster, typically for cluster-level services.

Kubernetes Job

A Kubernetes workload object that creates one or more Pods and ensures that a specified number of them successfully terminate.

  • Designed for batch processing and one-off tasks.
  • Pods created by a Job run to completion.
  • Can be configured to retry failed Pods.

Memory trick: Jobs get the 'job' done and then they're 'done'.

More Kubernetes Fundamentals questions