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 targetPort is 8080, not 80.
- ✗
The connection fails because the endpoints list is empty.
Why it's wrong here
The endpoints list is not empty; it contains one endpoint.
- ✗
The connection is randomly dropped due to missing port specification.
Why it's wrong here
The port specification is present and correct.
- ✓
The connection succeeds and reaches the pod on port 8080.
Why this is correct
The service is correctly configured with endpoints mapping port 80 to targetPort 8080.
Go deeper
Related to this question
About these practice questions
This CKA question is part of Courseiva's 302-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.