CKA Workloads & Scheduling Practice Question
A Pod with a restartPolicy of 'OnFailure' exits with code 0. What will happen?
⚠ Common exam trap
Test-takers frequently confuse 'OnFailure' with 'Always', assuming any exit triggers a restart, or they mistakenly think a Pod is 'terminated' (deleted) when it actually enters a terminal phase like Succeeded.
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
✓
The container will not restart, and the Pod will be in Succeeded phase.
When a Pod has a restartPolicy of 'OnFailure' and its container exits with code 0 (indicating successful completion), the container will not be restarted. Instead, the Pod transitions to the Succeeded phase, as defined by Kubernetes Pod lifecycle semantics. This is because 'OnFailure' only triggers a restart on a non-zero exit code, which signifies a failure.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The container will restart immediately.
Why it's wrong here
The kubelet checks the exit code against the restartPolicy: OnFailure only triggers a container restart when the exit code is non-zero, signaling a failure. Since this container exited with code 0, the kubelet classifies the run as successful and does not initiate any restart. Immediate restart regardless of exit status is exclusive to restartPolicy: Always, not OnFailure.
- ✗
The Pod will be terminated.
Why it's wrong here
A Pod is not terminated simply because its containers have finished running; instead, the Pod advances to a terminal phase based on the observed exit codes and the configured restartPolicy. With OnFailure and a zero exit code, the kubelet records the successful exit and moves the Pod to the Succeeded phase, leaving the Pod object present for inspection until it is deleted or garbage-collected. Actual Pod termination would require an explicit DELETE request or a node-level event such as eviction.
- ✗
The Pod will remain in Running state.
Why it's wrong here
The Running phase is reserved for Pods that still have at least one active container executing its main process. Once every container in the Pod has exited, the kubelet evaluates the final exit codes and updates the Pod's status to either Succeeded or Failed, so a Pod cannot remain in Running with zero running containers. The phase transition is instantaneous from the API server's perspective after the last container terminates.
- ✓
The container will not restart, and the Pod will be in Succeeded phase.
Why this is correct
With restartPolicy: OnFailure, an exit code of 0 means the container completed its workload successfully, so the kubelet deliberately avoids restarting it. Because all containers have exited with code 0 and no restart is warranted, the Pod's phase is set to Succeeded, which is the terminal state for successful Pod completion. This matches the expected behavior for batch or job-style workloads that should run to completion exactly once.
Go deeper
Related to this question
Learn chapter
Kubernetes Architecture Overview
Key term
Network Policies
A Kubernetes resource that controls how pods communicate with each other and with other network endpoints, acting as a firewall for pod-to-pod traffic.
Key term
Ingress Resources
Ingress Resources are Kubernetes API objects that manage external access to services inside a cluster, typically HTTP and HTTPS traffic, by defining rules for routing requests based on hostnames and paths.
About these practice questions
This CKA question is part of Courseiva's 302-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.