KCNA Kubernetes Fundamentals Practice Question
Which THREE of the following are valid ways to create a Kubernetes resource using kubectl?
⚠ Common exam trap
CNCF often tests the distinction between commands that create resources versus commands that interact with existing resources, so candidates may mistakenly think `kubectl exec` or `kubectl logs` can create resources because they are common kubectl commands.
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 nginx --image=nginx
Option B (kubectl run nginx --image=nginx) is correct because kubectl run creates a new resource (historically a Pod, and in newer versions a Pod via the run command) directly from the command line using the specified container image. Option D (kubectl create -f pod.yaml) is correct because kubectl create is an imperative command that builds a resource from a manifest file, here a Pod defined in pod.yaml. Option E (kubectl apply -f deployment.yaml) is correct because kubectl apply declaratively creates or updates the resource defined in deployment.yaml, making it a valid way to create a Kubernetes resource. Option A (kubectl exec -it pod-name -- /bin/bash) is incorrect because exec opens an interactive shell inside an existing container and does not create any resource. Option C (kubectl logs pod-name) is incorrect because logs only retrieves container log output from an existing Pod and has no resource-creation capability.
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 exec -it pod-name -- /bin/bash
Why it's wrong here
kubectl exec opens an interactive shell inside an already-running container; it creates nothing and requires the pod to exist first. It is tempting because it targets pods like create commands do, and it would be correct for debugging a live container by running commands within it.
- ✓
kubectl run nginx --image=nginx
Why this is correct
`kubectl run` creates a Pod imperatively, satisfying the stem's requirement for a valid resource-creation method. It submits the resource directly to the API server without a manifest file, unlike declarative `kubectl apply -f`. This imperative approach works for Pods, though newer kubectl versions restrict it to that resource type.
- ✗
kubectl logs pod-name
Why it's wrong here
kubectl logs retrieves container output from an existing pod; it performs no create operation and accepts no manifest, file or generator input. It is tempting because it is a common pod-scoped verb, and it would be the right command for inspecting a running container's stdout when diagnosing application errors.
- ✓
kubectl create -f pod.yaml
Why this is correct
`kubectl create -f pod.yaml` satisfies the requirement by submitting a declarative manifest file to the API server, which parses the YAML and creates the resource defined within it. This imperative command reads the file specified by `-f` and issues the corresponding create request, making it a valid creation method.
- ✓
kubectl apply -f deployment.yaml
Why this is correct
`kubectl apply -f deployment.yaml` creates or updates resources declaratively from a manifest file, satisfying the requirement for a valid creation method. Unlike `create`, `apply` reconciles desired state against the live cluster, making it idempotent and the standard approach for managing Kubernetes objects stored in YAML.
Go deeper
Related to this question
About these practice questions
This KCNA question is part of Courseiva's 930-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 KCNA 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 KCNA exam.