Courseiva

CKA Practice Question: Cluster Architecture, Installation and Configuration

A developer is creating a Pod with a single container that should restart only if the process exits with non-zero. Which restartPolicy should be used?

⚠ Common exam trap

Candidates often confuse Docker restart policies (like `unless-stopped`) with Kubernetes restart policies. Kubernetes only supports `Always`, `OnFailure`, and `Never`. Another major trap is forgetting that Deployments only support `Always`; if you need `OnFailure` or `Never` behavior, you must use a Pod or a Job.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

OnFailure

In Kubernetes, the `restartPolicy` for a Pod controls container restart behavior. The requirement is to restart only when the process exits with a non-zero code, which is exactly what `OnFailure` does. `Always` restarts on any exit (zero or non-zero), `Never` does not restart at all, and `UnlessStopped` is not a valid Kubernetes restart policy (it is a Docker restart policy). Note that while Pods and Jobs support `OnFailure`, workloads like Deployments, StatefulSets, and DaemonSets only support `Always`.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Never

    Why it's wrong here

    Never: This policy never restarts the container, so it does not satisfy the requirement of restarting on non-zero exit.

  • ✗

    Always

    Why it's wrong here

    Always: This policy restarts the container on any exit, including zero exit. The requirement is to restart only on non-zero exit, so this is incorrect because it restarts even on success.

  • ✗

    UnlessStopped

    Why it's wrong here

    UnlessStopped: This is not a valid restart policy in Kubernetes. Valid options are Always, OnFailure, and Never.

  • ✓

    OnFailure

    Why this is correct

    OnFailure: This policy restarts the container only when the process exits with a non-zero code, which matches the requirement exactly. Since Kubernetes 1.15, Deployments allow this policy.

About these practice questions

One of 726 original CKA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.