Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsMedium

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

  1. AReplicaSet
  2. BJob
  3. CDeployment
  4. DDaemonSet
Show answer & explanation

Correct answer: B. Job

A Kubernetes Job is designed for one-off, short-lived tasks that run to completion. It ensures that a specified number of Pods successfully complete their task and then terminates, unlike Deployments or DaemonSets which are for continuous, long-running services.

Why the other options are wrong

  • A. A ReplicaSet ensures a stable set of replica Pods running at any given time, primarily used by Deployments, not for completion-based tasks.
  • C. A Deployment is for long-running, stateless applications and maintains a desired number of replicas indefinitely.
  • D. A DaemonSet ensures that all (or some) nodes run a copy of a Pod, typically for cluster-level services, not one-off tasks.

Kubernetes Job

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

  • Designed for batch processing or one-off tasks.
  • Pods run to completion and then terminate.
  • Can specify parallelism for multiple completions.
  • Automatically cleans up completed Pods (configurable).

Memory trick: Deployment for services, Job for tasks, Daemon for every node, Replica for count.

More Kubernetes Fundamentals questions