KCNA Kubernetes Fundamentals Practice Question
Which TWO of the following are valid ways to expose a Deployment as a Service?
⚠ Common exam trap
Candidates often confuse 'kubectl run --expose' (which creates a Pod, not a Deployment) with exposing an existing Deployment, or incorrectly assume that a Deployment can contain a Service definition within its own YAML manifest.
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
✓
Run 'kubectl expose deployment my-deployment --port=80 --target-port=8080'
'kubectl expose deployment my-deployment --port=80 --target-port=8080' creates a Service object that selects pods based on the labels automatically assigned to the Deployment's pods. This command generates a ClusterIP Service by default, mapping port 80 on the Service to port 8080 on the pods, which is a standard and valid method to expose a Deployment.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Run 'kubectl expose deployment my-deployment --port=80 --target-port=8080'
Why this is correct
This command creates a Service based on the Deployment's pod labels.
- ✗
Edit the Deployment and set 'spec.serviceName'
Why it's wrong here
There is no such field in a Deployment spec.
- ✗
Run 'kubectl run my-deployment --image=nginx --expose'
Why it's wrong here
This creates a pod and a Service, but does not use an existing Deployment.
- ✗
Add a 'service' section to the Deployment's YAML manifest
Why it's wrong here
Deployments do not have a service section; Services are separate resources.
- ✓
Create a Service YAML with a selector matching the Deployment's pod labels
Why this is correct
A Service with appropriate selector will route traffic to the pods managed by the Deployment.
Go deeper
Related to this question
About these practice questions
Courseiva writes every KCNA question from scratch — 833 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.