Kubernetes and Cloud Native Associate (KCNA)Kubernetes FundamentalsEasy

A developer is preparing a YAML manifest for a new Kubernetes Pod. They intend for this Pod to run a container that executes a single, short-lived task to completion and then terminate. Which of the following Kubernetes object types is most appropriate for defining this kind of workload?

  1. AReplicaSet
  2. BDeployment
  3. CJob
  4. DStatefulSet
Show answer & explanation

Correct answer: C. Job

For tasks that run to completion, Kubernetes provides the Job object. Deployments, ReplicaSets, and StatefulSets are designed for long-running, continuously available applications.

Why the other options are wrong

  • A. ReplicaSets ensure a specified number of Pod replicas are running at all times, not for completion-based tasks.
  • B. Deployments are for long-running, stateless applications that need to be continuously available.
  • D. StatefulSets are used for stateful applications, ensuring ordered deployment and unique network identities for Pods.

Kubernetes Job

A Kubernetes Job creates one or more Pods and ensures that a specified number of them successfully terminate. It's used for batch processing or single-time tasks.

  • Ensures Pods run to completion.
  • Automatically retries failed Pods.
  • Can run multiple Pods in parallel for a single task.

Memory trick: Jobs Execute Once, Deployments Forever

More Kubernetes Fundamentals questions