Hint: ClusterIP service YAML must specify type: ClusterIP [OK]
Common Mistakes:
Using wrong service type like NodePort
Confusing Pod definition with Service
Omitting service type field
3. Given this service YAML with type ClusterIP, what will be the output of kubectl get svc my-service?
medium
A. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service ClusterIP 10.96.0.1 <none> 80/TCP 5m
B. NAME TYPE EXTERNAL-IP PORT(S) AGE
my-service LoadBalancer 192.168.1.1 80/TCP 5m
C. Error: service not found
D. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service NodePort 10.96.0.1 <none> 80:30080/TCP 5m
Solution
Step 1: Understand ClusterIP service output
ClusterIP services show a cluster internal IP and no external IP.
Step 2: Match output format
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service ClusterIP 10.96.0.1 <none> 80/TCP 5m shows ClusterIP type with a cluster IP and <none> external IP, matching expected output.
Final Answer:
Service listed with ClusterIP and no external IP -> Option A
Quick Check:
ClusterIP service output = NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service ClusterIP 10.96.0.1 <none> 80/TCP 5m [OK]
Hint: ClusterIP services have no external IP in kubectl output [OK]
Common Mistakes:
Expecting external IP for ClusterIP service
Confusing LoadBalancer or NodePort output
Assuming service not found error
4. You created a ClusterIP service but pods cannot reach it. Which YAML mistake could cause this?
medium
A. Using type: LoadBalancer instead of ClusterIP
B. Missing or incorrect selector labels in the service spec
C. Specifying targetPort as a string instead of a number
D. Omitting the metadata section
Solution
Step 1: Identify service selector role
The selector connects the service to the correct pods. If missing or wrong, no pods match.
Step 2: Evaluate other options
Type LoadBalancer changes exposure but doesn't block pod access. targetPort as string is accepted. metadata omission causes other errors but not pod reachability.
Final Answer:
Missing or incorrect selector labels -> Option B
Quick Check:
Selector connects pods = Missing or incorrect selector labels in the service spec [OK]
Hint: Check selector labels to link service and pods [OK]
Common Mistakes:
Ignoring selector labels importance
Blaming service type for pod connectivity
Confusing metadata omission with connectivity issues
5. You want to expose a web app only inside your Kubernetes cluster using a ClusterIP service. Which combination of YAML fields ensures this?