KCNA Kubernetes Fundamentals Practice Question
Which of the following is a correct YAML structure for a Service of type ClusterIP?
⚠ Common exam trap
A common pitfall is confusing the apiVersion for core resources (v1) with that of named API groups (e.g., apps/v1). Candidates often mistakenly use apps/v1 for Services, or confuse the Service spec structure with that of a Pod or Deployment.
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: my-service spec: selector: app: myapp ports: - port: 80
It defines a Kubernetes Service of kind Service with apiVersion v1, which is the correct API group for core Service objects. The spec includes a selector to target pods with label app: myapp and a port mapping with port 80, which is the standard structure for a ClusterIP Service (the default type when type is omitted). The selector field is required to route traffic to matching pods, and the ports array correctly specifies the service port.
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: my-service spec: selector: app: myapp ports: - port: 80
Why this is correct
This manifest declares apiVersion v1, kind Service, and a spec containing a label selector plus a ports entry with port 80. Omitting type defaults to ClusterIP, so the structure is a valid ClusterIP Service definition.
- ✗
apiVersion: v1 kind: Pod metadata: name: my-service spec: selector: app: myapp ports: - port: 80
Why it's wrong here
kind: Pod creates a pod, not a Service, so no stable ClusterIP or service DNS name is produced. It is tempting because the selector and ports syntax resembles a Service definition, and would be correct when deploying a single workload that needs no service discovery.
- ✗
apiVersion: apps/v1 kind: Service metadata: name: my-service spec: selector: app: myapp ports: - port: 80
Why it's wrong here
apiVersion: apps/v1 is used by Deployments, StatefulSets and DaemonSets; Services require v1, so the manifest is rejected. It is tempting because the kind, selector and ports are otherwise correct, and would be right when defining a Deployment that manages the backing pods.
- ✗
apiVersion: v1 kind: Service metadata: name: my-service spec: app: myapp ports: - port: 80
Why it's wrong here
The spec places 'app: myapp' directly under spec instead of within a selector, and omits type: ClusterIP, so the Service selects no pods. It is tempting because the apiVersion, kind and ports mirror a valid Service, and would be correct once the label moves into spec.selector.
Go deeper
Related to this question
Learn chapter
Kubernetes Overview and Core Components
Key term
ReplicaSet and Replication
A ReplicaSet ensures a specified number of identical pod instances are running at all times in Kubernetes, using replication to maintain availability and stability.
Key term
Kubernetes API Primitives
Kubernetes API Primitives are the basic building blocks that the Kubernetes API uses to represent and manage the state of a cluster, such as Pods, Services, Deployments, and Namespaces.
About these practice questions
One of 930 original KCNA 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 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.