Courseiva
Workloads and Scheduling →mediumMultiple Choice

CKA Workloads and Scheduling Practice Question

You have a Pod that needs to run a database migration before the main application container starts. Which Kubernetes concept should you use?

⚠ Common exam trap

Many candidates confuse init containers with sidecar containers or PostStart hooks, not realizing that init containers are the only option that guarantees sequential execution before the main container starts, while sidecars run concurrently and PostStart hooks run after the main container has already started.

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

✓

Init container

Init containers are designed to run to completion before the main application containers start, making them the ideal Kubernetes primitive for tasks like database migrations that must complete before the primary service begins. Unlike sidecars, init containers do not run concurrently with the main container, ensuring the migration finishes before the application container starts.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Sidecar container

    Why it's wrong here

    Sidecar containers are designed to run concurrently alongside the primary application container to extend or enhance its functionality, such as for logging or monitoring. Because they execute in parallel with the main container rather than completing beforehand, they cannot guarantee that database migrations are fully executed before the application attempts to connect.

  • ✓

    Init container

    Why this is correct

    Init containers are specialized containers that run to completion sequentially before any app containers in the Pod are started. If an init container fails, Kubernetes restarts the Pod repeatedly until it succeeds, making it the ideal mechanism to block the main application until database migrations are successfully applied.

  • ✗

    PostStart hook

    Why it's wrong here

    The PostStart handler executes immediately after a container is created, but there is no guarantee that it will run before the container's entrypoint is executed. Because it runs asynchronously and concurrently with the main container's startup process, it is unsafe for blocking tasks like database migrations which must finish before the application starts.

  • ✗

    Job

    Why it's wrong here

    A Kubernetes Job is an independent, top-level controller designed to run short-lived, batch tasks to completion. While a Job can execute migrations, it operates under its own lifecycle outside of the application Pod, meaning you would need external orchestration to prevent the application Pod from starting before the Job finishes.

About these practice questions

This CKA question is part of Courseiva's 726-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 →

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.