CKA Services & Networking Practice Question
Exhibit
Refer to the exhibit.
$ kubectl get svc my-service -o yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
clusterIP: 10.96.0.1
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
selector:
app: my-app
type: ClusterIP
status:
loadBalancer: {}
$ kubectl get endpoints my-service
NAME ENDPOINTS AGE
my-service 192.168.1.10:8080 5mGiven the following YAML manifests in the same namespace: ```yaml apiVersion: v1 kind: Pod metadata: name: my-pod labels: app: my-app spec: containers: - name: app image: nginx ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: my-app ports: - port: 80 targetPort: 8080 ``` A pod in the same namespace tries to reach my-service on port 80. What is the most likely outcome?
⚠ Common exam trap
Candidates often assume the Service's `port` automatically maps to the container's listening port, but Kubernetes defaults `targetPort` to the same value as `port`, not to the container's port, so a mismatch causes connection failures unless explicitly configured.
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
✓
The connection succeeds and reaches the pod on port 8080.
The Service my-service is configured with port: 80 and targetPort: 8080. Therefore, traffic sent to the Service on port 80 is forwarded to the pod's container port 8080, and the connection succeeds, reaching the pod on port 8080. If targetPort were not set, it would default to port 80, causing the connection to fail because the pod listens on 8080.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The connection succeeds but reaches the pod on port 80.
Why it's wrong here
The Service maps port 80 to targetPort 8080, so kube-proxy DNATs the connection to 8080 on the pod; the container listens on 8080, not 80, so nothing answers on 80. The port field is the Service's own listening port, and targetPort is what the backend receives.
- ✗
The connection fails because the endpoints list is empty.
Why it's wrong here
The selector app: my-app matches the pod's label exactly, so the Endpoints controller populates the endpoints list and traffic is forwarded normally. An empty endpoints list occurs only when the Service selector matches no ready pod, which is not the case here.
- ✗
The connection is randomly dropped due to missing port specification.
Why it's wrong here
Kubernetes does not randomly drop traffic for a missing port specification; the manifest defines both port 80 and targetPort 8080, so the mapping is complete. Random drops would indicate kube-proxy or conntrack faults, not absent configuration.
- ✓
The connection succeeds and reaches the pod on port 8080.
Why this is correct
The Service selects the pod via the matching `app: my-app` label, and its `targetPort: 8080` forwards traffic to the container's declared `containerPort`. kube-proxy programs the cluster IP so requests to port 80 are DNAT'd to the pod's IP on 8080, satisfying the same-namespace reachability constraint.
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 →
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.