CKAD Services and Networking Practice Question
Which command creates a Service named 'my-svc' that exposes a deployment named 'my-deploy' on port 80?
⚠ Common exam trap
It's easy for candidates to confuse `kubectl create service` (which requires a service type and does not link to a deployment) with `kubectl expose` (which is the correct imperative command to create a Service from an existing resource), leading them to pick Option A or C without realizing the missing selector linkage.
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 expose deployment my-deploy --name=my-svc --port=80
The `kubectl expose` command is specifically designed to create a Service from an existing resource like a Deployment. By specifying `deployment my-deploy`, `--name=my-svc`, and `--port=80`, it generates a ClusterIP Service that routes traffic to the pods selected by the deployment's labels on port 80.
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 create service my-svc --port=80 --target-port=80
Why it's wrong here
This command creates a Service object with the specified ports but attaches no selector, so the Service's endpoints will remain empty. Because the Service is not linked to any deployment, Kubernetes will not route traffic to any pods. The correct way to expose an existing deployment is to use `kubectl expose`, which automatically sets the selector based on the deployment's pod template.
- ✗
kubectl run my-svc --expose --port=80 --image=my-image
Why it's wrong here
This command creates a new pod (or deployment, depending on the Kubernetes version) along with a Service that selects that new workload's labels. It does not create a Service from the existing deployment `my-deploy`; rather, it spins up a separate workload named `my-svc` and exposes it. The requirement is to expose an already-existing deployment, so this command fails the intent even though it does produce a Service.
- ✗
kubectl create svc clusterip my-svc --tcp=80:80
Why it's wrong here
The `kubectl create svc clusterip` shorthand generates a ClusterIP Service with the specified port/target-port mapping but without a selector, leaving it disconnected from any pods. Like the `create service` variant, this is a standalone Service object that does not reference `my-deploy`. To expose a deployment, you must either pass a selector in the manifest or use `kubectl expose`, which builds the selector from the deployment's labels.
- ✓
kubectl expose deployment my-deploy --name=my-svc --port=80
Why this is correct
This is the correct command because it creates a Service from an existing deployment. `kubectl expose` reads the deployment's label selector and applies it to the Service, ensuring the Service forwards traffic to the pods managed by `my-deploy`. The `--name` flag customizes the Service name while `--port=80` defines the exposed port, with `targetPort` defaulting to the pod's container port.
Go deeper
Related to this question
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 →
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.