CKAD Services and Networking Practice Question
A StatefulSet named 'mysql' is deployed with 3 replicas. The administrator wants to create a headless Service so that each pod gets a unique DNS entry. Which Service specification should be used?
⚠ Common exam trap
It's easy for candidates to confuse setting `clusterIP: None` with leaving `clusterIP` empty or using an invalid value like `""`, or they mistakenly think a NodePort or default ClusterIP Service can provide per-pod DNS entries for StatefulSets.
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
✓
apiVersion: v1 kind: Service metadata: name: mysql spec: clusterIP: None selector: app: mysql ports: - port: 3306
Setting `clusterIP: None` creates a headless Service, which is required for StatefulSets to provide stable network identities and unique DNS entries for each pod. A headless Service does not load-balance traffic; instead, it returns the pod IPs directly, enabling DNS resolution to individual pod hostnames like `mysql-0.mysql.default.svc.cluster.local`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
apiVersion: v1 kind: Service metadata: name: mysql spec: type: NodePort selector: app: mysql ports: - port: 3306
Why it's wrong here
A NodePort Service exposes the MySQL port on every node in the cluster via a node port, but it still has a virtual ClusterIP and does not provide the per-pod DNS records that StatefulSet pods require. Headless services do not have a ClusterIP, so NodePort cannot create the stable network identities (mysql-0.mysql, mysql-1.mysql) that a StatefulSet depends on. It is intended for external access, not for direct pod-to-pod communication within a stateful workload.
- ✓
apiVersion: v1 kind: Service metadata: name: mysql spec: clusterIP: None selector: app: mysql ports: - port: 3306
Why this is correct
Setting clusterIP: None creates a headless Service, which publishes the individual pod IPs and DNS names for a StatefulSet. When the selector matches the pods, Kubernetes creates A records like mysql-0.mysql.namespace.svc.cluster.local for each replica, enabling clients to address a specific pod. This is the correct way to provide stable network identities for stateful applications, which is exactly what a StatefulSet requires.
- ✗
apiVersion: v1 kind: Service metadata: name: mysql spec: type: ClusterIP selector: app: mysql ports: - port: 3306
Why it's wrong here
A regular ClusterIP Service creates a virtual IP that load-balances traffic to all matching pods, obscuring the individual pod identity. While it may serve the database at mysql:3306, it does not create the per-pod DNS entries required by the StatefulSet's stable network identity. StatefulSets need to resolve specific pod hostnames, and only a headless service publishes those records instead of hiding the pods behind a single virtual IP.
- ✗
apiVersion: v1 kind: Service metadata: name: mysql spec: clusterIP: "" selector: app: mysql ports: - port: 3306
Why it's wrong here
Using clusterIP: "" does not produce a headless service; in Kubernetes, the special value must be the string None. An empty string is treated as an unset field, so the Service will be created with a normal ClusterIP (or fail validation depending on the API version). Consequently, it will not generate per-pod DNS records for the StatefulSet, and the workload will still suffer from the same identity problem as a regular ClusterIP service.
Visual reference
Go deeper
Related to this question
About these practice questions
This CKAD question is part of Courseiva's 826-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 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.