Courseiva

CKAD Application Design and Build Practice Question

Which 'kubectl' command creates a pod named 'test-pod' using the nginx image and outputs the YAML manifest without actually creating it?

⚠ Common exam trap

The CKAD exam often tests the distinction between `--dry-run=client` and `--dry-run=server`, and the requirement for output format (`-o yaml` vs `-o json`), tricking candidates into choosing an option that either does not output the manifest or outputs it in the wrong format.

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

✓

kubectl run test-pod --image=nginx --dry-run=client -o yaml

`kubectl run test-pod --image=nginx --dry-run=client -o yaml` generates the YAML manifest for a pod named 'test-pod' using the nginx image without actually creating it. The `--dry-run=client` flag simulates the request locally and prevents API server submission, while `-o yaml` formats the output as YAML.

Answer analysis

Option-by-option breakdown

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

  • ✗

    kubectl apply -f pod.yaml

    Why it's wrong here

    The `apply -f` subcommand is declarative and requires a pre-existing YAML or JSON manifest file; it sends that file to the API server to create or update resources. It does not generate a manifest from command-line arguments, so running it without a valid `pod.yaml` fails, and it would not produce the requested YAML output. In the context of the question, you need a command that creates a manifest, not one that consumes one.

  • ✓

    kubectl run test-pod --image=nginx --dry-run=client -o yaml

    Why this is correct

    This is the canonical imperative command for manifest generation: `kubectl run` creates a Pod object from flags, `--dry-run=client` tells kubectl to only print the object locally without sending anything to the API server, and `-o yaml` formats that object as YAML on stdout. It gives you a complete Pod spec (with default values and a generated name) that you can review, edit, or pipe to `kubectl apply -f -`. This is precisely what the question asks for — a command that generates a Pod manifest without creating the Pod.

  • ✗

    kubectl run test-pod --image=nginx --dry-run=server

    Why it's wrong here

    The `--dry-run=server` option submits the object to the API server, where it passes through admission control and validation, but the object is not persisted — the server simulates the creation and reports the outcome. Because no `-o` flag is provided, kubectl does not output a YAML manifest; it just prints something like `pod/test-pod created (dry run)`. Since the goal is to generate YAML for a Pod named `test-pod`, this server-side variant both fails to produce the desired output and unnecessarily invokes the API server.

  • ✗

    kubectl run test-pod --image=nginx --dry-run=client -o json

    Why it's wrong here

    Like the correct answer, this performs a client-side dry run and produces a Pod manifest, but the `-o json` flag changes the output serialization to JSON instead of YAML. The JSON document is a valid Kubernetes manifest, but the question specifically asks for YAML output, so this command does not meet the requirement. Additionally, if you later wanted to pipe to `kubectl apply`, JSON works too, but the expected convention in exams and practice is YAML for readability.

About these practice questions

One of 826 original CKAD 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 CKAD 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 CKAD exam.