CKA Domain 3: Services and Networking
39 free practice questions for Services and Networking in the Certified Kubernetes Administrator (CKA) exam. Try each question first, then open "Show answer" for the correct option and explanation.
Services and Networking practice questions
-
Question 1. Which Service type exposes an application only inside the cluster?
Show answer
Answer: C. ClusterIP
ClusterIP is the default type and gives a stable internal virtual IP.
-
Question 2. Which Service type opens the same port on every node to reach the application?
Show answer
Answer: B. NodePort
NodePort allocates a port, 30000–32767 by default, on each node.
-
Question 3. Which Service type provisions an external load balancer in supported cloud environments?
Show answer
Answer: B. LoadBalancer
LoadBalancer builds on NodePort and asks the cloud provider for a load balancer.
-
Question 4. A Service has no endpoints. What is the MOST likely cause?
Show answer
Answer: A. Its selector doesn't match the labels on any ready Pod
Endpoints come from Pods matching the selector that pass readiness checks.
-
Question 5. Which command exposes Deployment web on port 80, forwarding to container port 8080?
Show answer
Answer: B. kubectl expose deployment web --port=80 --target-port=8080
expose creates a Service using the Deployment's selector.
-
Question 6. How can you view the Pod IPs currently behind Service web?
Show answer
Answer: B. kubectl get endpointslices -l kubernetes.io/service-name=web
EndpointSlices track the backend addresses for Services.
-
Question 7. What is a headless Service?
Show answer
Answer: B. A Service with clusterIP: None that returns Pod IPs directly in DNS
Headless Services are often used with StatefulSets so each Pod gets its own DNS record.
-
Question 8. What DNS name reaches Service api in namespace shop from another namespace?
Show answer
Answer: D. api.shop.svc.cluster.local
Service DNS names follow service.namespace.svc.cluster-domain.
-
Question 9. Which component provides DNS for Services and Pods in most clusters?
Show answer
Answer: C. CoreDNS
CoreDNS runs as a Deployment in kube-system and is configured with a ConfigMap.
-
Question 10. Which component programs iptables or IPVS rules so Service IPs reach Pods?
Show answer
Answer: C. kube-proxy
kube-proxy watches Services and EndpointSlices and updates node networking rules. Some CNIs replace it.
-
Question 11. By default, without any NetworkPolicy, what traffic is allowed between Pods?
Show answer
Answer: B. All Pods can communicate with each other
The Kubernetes network model allows all Pod-to-Pod traffic unless policies restrict it.
-
Question 12. What must be true for NetworkPolicies to take effect?
Show answer
Answer: C. The CNI plugin must support NetworkPolicy
Policies are enforced by the network plugin. Some plugins, such as basic flannel, don't enforce them.
-
Question 13. A NetworkPolicy selects Pods with app=db and has an empty ingress rule list. What happens to ingress traffic to those Pods?
Show answer
Answer: B. All ingress is denied
Once a Pod is selected for ingress, only traffic matching an ingress rule is allowed. No rules means deny all.
-
Question 14. A policy should allow traffic to app=db only from Pods labeled app=api in the same namespace. Which ingress rule fits?
Show answer
Answer: D. from: - podSelector: matchLabels: app: api
podSelector in a from block selects source Pods in the policy's namespace.
-
Question 15. How do you allow traffic from all Pods in namespaces labeled team=frontend?
Show answer
Answer: A. Use a namespaceSelector with matchLabels team=frontend
namespaceSelector matches namespaces by their labels.
-
Question 16. A NetworkPolicy restricts egress for app=web. What must usually be allowed so the Pods can still resolve names?
Show answer
Answer: D. Egress to CoreDNS on port 53 (UDP and TCP)
When egress is restricted, DNS must be explicitly allowed or name resolution fails.
-
Question 17. What is the purpose of an Ingress resource?
Show answer
Answer: D. Route external HTTP/HTTPS traffic to Services based on host and path
Ingress rules route requests to Services. TLS can be terminated at the Ingress.
-
Question 18. An Ingress resource was created but nothing happens. What is MOST likely missing?
Show answer
Answer: C. An Ingress controller running in the cluster
Ingress resources do nothing without a controller such as ingress-nginx.
-
Question 19. Which field selects which Ingress controller handles an Ingress?
Show answer
Answer: B. spec.ingressClassName
IngressClass lets several controllers coexist in one cluster.
-
Question 20. What does the Gateway API offer compared with Ingress?
Show answer
Answer: D. Role-oriented resources such as GatewayClass, Gateway, and HTTPRoute
The Gateway API separates infrastructure and routing roles and supports richer routing.
-
Question 21. In the Gateway API, which resource defines host and path rules that send traffic to Services?
Show answer
Answer: D. HTTPRoute
Gateways define listeners, and HTTPRoutes attach to them with routing rules.
-
Question 22. Which command forwards local port 8080 to port 80 of a Service for testing?
Show answer
Answer: D. kubectl port-forward svc/web 8080:80
port-forward creates a temporary tunnel through the API server.
-
Question 23. Which statement about Pod networking is correct?
Show answer
Answer: C. Each Pod gets its own IP, and containers in a Pod share it
Containers in a Pod share a network namespace and can reach each other on localhost.
-
Question 24. Which setting lets a Pod use the node's network namespace directly?
Show answer
Answer: C. hostNetwork: true
hostNetwork is used by some system Pods but reduces isolation.
-
Question 25. Which Service field exposes a Service on a fixed node port, such as 30080?
Show answer
Answer: D. spec.ports[].nodePort
If nodePort isn't set, Kubernetes picks one from the allowed range.
-
Question 26. A Pod can't resolve Service names. Which component should be checked FIRST?
Show answer
Answer: B. The CoreDNS Pods in kube-system
Check that CoreDNS Pods are running and that the Pod's /etc/resolv.conf points to the cluster DNS IP.
-
Question 27. Where is the CoreDNS configuration stored?
Show answer
Answer: B. In the coredns ConfigMap in kube-system
The Corefile in the ConfigMap defines plugins, zones, and upstream forwarding.
-
Question 28. Which Service type maps a Service name to an external DNS name with a CNAME?
Show answer
Answer: C. ExternalName
ExternalName returns a CNAME and doesn't proxy traffic.
-
Question 29. What does the targetPort of a Service refer to?
Show answer
Answer: B. The port on the Pods that receives traffic
port is the Service port, targetPort is the container port, and nodePort is on the nodes.
-
Question 30. Which NetworkPolicy blocks all ingress traffic to every Pod in a namespace?
Show answer
Answer: C. podSelector: {} with policyTypes: [Ingress] and no ingress rules
An empty podSelector selects all Pods. With no ingress rules, all ingress is denied.
-
Question 31. How can you test connectivity from inside the cluster to a Service?
Show answer
Answer: D. Run a temporary busybox Pod and use wget or nslookup
kubectl run tmp --rm -it --image=busybox -- sh is a common way to test DNS and connectivity.
-
Question 32. Which Pod setting controls how DNS resolution works for that Pod?
Show answer
Answer: B. dnsPolicy
The default ClusterFirst uses cluster DNS. None lets you set dnsConfig manually.
-
Question 33. Which network setting on a Service keeps client source IPs and only sends traffic to Pods on the receiving node?
Show answer
Answer: D. externalTrafficPolicy: Local
Local preserves the client IP and avoids an extra hop, but nodes without Pods receive no traffic.
-
Question 34. Which field in an Ingress configures HTTPS using a certificate stored in a Secret?
Show answer
Answer: C. spec.tls with hosts and secretName
The TLS Secret must hold tls.crt and tls.key in the Ingress's namespace.
-
Question 35. What does pathType: Prefix mean in an Ingress rule?
Show answer
Answer: A. The path matches the given prefix, split by slashes
Prefix /api matches /api and /api/v1, but not /apiv2. Exact requires an exact match.
-
Question 36. How many NetworkPolicies can select the same Pod?
Show answer
Answer: B. Many; their allowed traffic is combined
NetworkPolicies are additive. Traffic is allowed if any policy allows it.
-
Question 37. Which component assigns IP addresses to Pods?
Show answer
Answer: B. The CNI plugin, when the Pod's sandbox is created
The CNI plugin sets up the Pod's network interface and assigns an IP from its range.
-
Question 38. What is the default range for NodePort Services?
Show answer
Answer: A. 30000–32767
The range can be changed with the API server's --service-node-port-range flag.
-
Question 39. A Service's ClusterIP responds, but only some requests fail. Which check is MOST useful?
Show answer
Answer: B. Whether some backend Pods are unhealthy
Intermittent failures often come from one bad backend Pod receiving a share of traffic.
CKA, Certified Kubernetes Administrator, and Kubernetes are trademarks of The Linux Foundation. These questions are original study material, not questions from the real exam.