CKA · Domain 3 of 5 · 20% of the exam

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

  1. Question 1. Which Service type exposes an application only inside the cluster?

    1. NodePort
    2. LoadBalancer
    3. ClusterIP
    4. ExternalName
    Show answer

    Answer: C. ClusterIP

    ClusterIP is the default type and gives a stable internal virtual IP.

  2. Question 2. Which Service type opens the same port on every node to reach the application?

    1. ClusterIP
    2. NodePort
    3. ExternalName
    4. Headless
    Show answer

    Answer: B. NodePort

    NodePort allocates a port, 30000–32767 by default, on each node.

  3. Question 3. Which Service type provisions an external load balancer in supported cloud environments?

    1. NodePort
    2. LoadBalancer
    3. ClusterIP
    4. ExternalName
    Show answer

    Answer: B. LoadBalancer

    LoadBalancer builds on NodePort and asks the cloud provider for a load balancer.

  4. Question 4. A Service has no endpoints. What is the MOST likely cause?

    1. Its selector doesn't match the labels on any ready Pod
    2. The Service type is ClusterIP
    3. The namespace has too many Services
    4. The kube-scheduler is not running
    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.

  5. Question 5. Which command exposes Deployment web on port 80, forwarding to container port 8080?

    1. kubectl create service web --port=8080:80
    2. kubectl expose deployment web --port=80 --target-port=8080
    3. kubectl port-forward deployment/web 80:8080 --expose
    4. kubectl run web --expose --port=8080
    Show answer

    Answer: B. kubectl expose deployment web --port=80 --target-port=8080

    expose creates a Service using the Deployment's selector.

  6. Question 6. How can you view the Pod IPs currently behind Service web?

    1. kubectl describe node web --show-endpoints
    2. kubectl get endpointslices -l kubernetes.io/service-name=web
    3. kubectl get pods --service=web -o wide
    4. kubectl logs service/web --endpoints
    Show answer

    Answer: B. kubectl get endpointslices -l kubernetes.io/service-name=web

    EndpointSlices track the backend addresses for Services.

  7. Question 7. What is a headless Service?

    1. A Service with no selector and no ports
    2. A Service with clusterIP: None that returns Pod IPs directly in DNS
    3. A Service that is only reachable from outside
    4. A Service that load-balances across namespaces
    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.

  8. Question 8. What DNS name reaches Service api in namespace shop from another namespace?

    1. shop.api.svc.cluster.local
    2. api.svc.shop.cluster.local
    3. api.cluster.local.shop.svc
    4. api.shop.svc.cluster.local
    Show answer

    Answer: D. api.shop.svc.cluster.local

    Service DNS names follow service.namespace.svc.cluster-domain.

  9. Question 9. Which component provides DNS for Services and Pods in most clusters?

    1. kube-proxy
    2. etcd
    3. CoreDNS
    4. kubelet
    Show answer

    Answer: C. CoreDNS

    CoreDNS runs as a Deployment in kube-system and is configured with a ConfigMap.

  10. Question 10. Which component programs iptables or IPVS rules so Service IPs reach Pods?

    1. kubelet
    2. CoreDNS
    3. kube-proxy
    4. kube-scheduler
    Show answer

    Answer: C. kube-proxy

    kube-proxy watches Services and EndpointSlices and updates node networking rules. Some CNIs replace it.

  11. Question 11. By default, without any NetworkPolicy, what traffic is allowed between Pods?

    1. No Pods can communicate
    2. All Pods can communicate with each other
    3. Only Pods in the same namespace can communicate
    4. Only Pods on the same node can communicate
    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.

  12. Question 12. What must be true for NetworkPolicies to take effect?

    1. The Service type must be NodePort
    2. The kube-proxy must run in IPVS mode
    3. The CNI plugin must support NetworkPolicy
    4. The namespace must have a ResourceQuota
    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.

  13. Question 13. A NetworkPolicy selects Pods with app=db and has an empty ingress rule list. What happens to ingress traffic to those Pods?

    1. All ingress is allowed
    2. All ingress is denied
    3. Only traffic from the same node is allowed
    4. The policy is ignored
    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.

  14. Question 14. A policy should allow traffic to app=db only from Pods labeled app=api in the same namespace. Which ingress rule fits?

    1. from: - namespaceSelector: {}
    2. from: - ipBlock: cidr: 0.0.0.0/0
    3. to: - podSelector: matchLabels: app: api
    4. from: - podSelector: matchLabels: app: api
    Show answer

    Answer: D. from: - podSelector: matchLabels: app: api

    podSelector in a from block selects source Pods in the policy's namespace.

  15. Question 15. How do you allow traffic from all Pods in namespaces labeled team=frontend?

    1. Use a namespaceSelector with matchLabels team=frontend
    2. Use a podSelector with team=frontend
    3. Use an ipBlock with the namespace name
    4. Use a Service selector with team=frontend
    Show answer

    Answer: A. Use a namespaceSelector with matchLabels team=frontend

    namespaceSelector matches namespaces by their labels.

  16. Question 16. A NetworkPolicy restricts egress for app=web. What must usually be allowed so the Pods can still resolve names?

    1. Ingress from the API server on port 6443
    2. Egress to etcd on port 2379
    3. Ingress from kubelet on port 10250
    4. Egress to CoreDNS on port 53 (UDP and TCP)
    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.

  17. Question 17. What is the purpose of an Ingress resource?

    1. Expose Pods through NodePorts on every node
    2. Encrypt traffic between Pods
    3. Assign IPs to Pods
    4. Route external HTTP/HTTPS traffic to Services based on host and path
    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.

  18. Question 18. An Ingress resource was created but nothing happens. What is MOST likely missing?

    1. A CSI driver
    2. A LoadBalancer Service for every backend
    3. An Ingress controller running in the cluster
    4. The metrics server
    Show answer

    Answer: C. An Ingress controller running in the cluster

    Ingress resources do nothing without a controller such as ingress-nginx.

  19. Question 19. Which field selects which Ingress controller handles an Ingress?

    1. metadata.namespace
    2. spec.ingressClassName
    3. spec.backend.serviceName
    4. spec.tls.hosts
    Show answer

    Answer: B. spec.ingressClassName

    IngressClass lets several controllers coexist in one cluster.

  20. Question 20. What does the Gateway API offer compared with Ingress?

    1. A replacement for Services of type ClusterIP
    2. A DNS server for Pods
    3. Storage for application data
    4. Role-oriented resources such as GatewayClass, Gateway, and HTTPRoute
    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.

  21. Question 21. In the Gateway API, which resource defines host and path rules that send traffic to Services?

    1. GatewayClass
    2. IngressClass
    3. EndpointSlice
    4. HTTPRoute
    Show answer

    Answer: D. HTTPRoute

    Gateways define listeners, and HTTPRoutes attach to them with routing rules.

  22. Question 22. Which command forwards local port 8080 to port 80 of a Service for testing?

    1. kubectl expose svc/web 8080:80
    2. kubectl proxy svc/web 8080
    3. kubectl tunnel svc/web 8080:80
    4. kubectl port-forward svc/web 8080:80
    Show answer

    Answer: D. kubectl port-forward svc/web 8080:80

    port-forward creates a temporary tunnel through the API server.

  23. Question 23. Which statement about Pod networking is correct?

    1. Each container in a Pod gets its own IP
    2. Pods share the node's IP by default
    3. Each Pod gets its own IP, and containers in a Pod share it
    4. Pods have no IP until exposed by a Service
    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.

  24. Question 24. Which setting lets a Pod use the node's network namespace directly?

    1. dnsPolicy: ClusterFirst
    2. shareProcessNamespace: true
    3. hostNetwork: true
    4. hostIPC: true
    Show answer

    Answer: C. hostNetwork: true

    hostNetwork is used by some system Pods but reduces isolation.

  25. Question 25. Which Service field exposes a Service on a fixed node port, such as 30080?

    1. spec.ports[].targetPort
    2. spec.clusterIP
    3. spec.externalName
    4. spec.ports[].nodePort
    Show answer

    Answer: D. spec.ports[].nodePort

    If nodePort isn't set, Kubernetes picks one from the allowed range.

  26. Question 26. A Pod can't resolve Service names. Which component should be checked FIRST?

    1. The etcd data directory on the control plane
    2. The CoreDNS Pods in kube-system
    3. The container runtime version on the node
    4. The kube-scheduler logs on the control plane
    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.

  27. Question 27. Where is the CoreDNS configuration stored?

    1. In /etc/resolv.conf on every node
    2. In the coredns ConfigMap in kube-system
    3. In the kube-proxy DaemonSet
    4. In the API server manifest
    Show answer

    Answer: B. In the coredns ConfigMap in kube-system

    The Corefile in the ConfigMap defines plugins, zones, and upstream forwarding.

  28. Question 28. Which Service type maps a Service name to an external DNS name with a CNAME?

    1. ClusterIP
    2. NodePort
    3. ExternalName
    4. LoadBalancer
    Show answer

    Answer: C. ExternalName

    ExternalName returns a CNAME and doesn't proxy traffic.

  29. Question 29. What does the targetPort of a Service refer to?

    1. The port clients use to reach the Service
    2. The port on the Pods that receives traffic
    3. The port opened on each node
    4. The port of the API server
    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.

  30. Question 30. Which NetworkPolicy blocks all ingress traffic to every Pod in a namespace?

    1. podSelector: {} with ingress: [{}]
    2. podSelector: {app: none} with egress rules only
    3. podSelector: {} with policyTypes: [Ingress] and no ingress rules
    4. namespaceSelector: {} with policyTypes: [Egress]
    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.

  31. Question 31. How can you test connectivity from inside the cluster to a Service?

    1. SSH into the etcd Pod and ping the Service IP
    2. Check the kube-scheduler logs for the Service
    3. Run kubectl top service to see traffic levels
    4. Run a temporary busybox Pod and use wget or nslookup
    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.

  32. Question 32. Which Pod setting controls how DNS resolution works for that Pod?

    1. restartPolicy
    2. dnsPolicy
    3. serviceAccountName
    4. priorityClassName
    Show answer

    Answer: B. dnsPolicy

    The default ClusterFirst uses cluster DNS. None lets you set dnsConfig manually.

  33. Question 33. Which network setting on a Service keeps client source IPs and only sends traffic to Pods on the receiving node?

    1. externalTrafficPolicy: Cluster
    2. sessionAffinity: None
    3. internalTrafficPolicy: Cluster
    4. externalTrafficPolicy: Local
    Show answer

    Answer: D. externalTrafficPolicy: Local

    Local preserves the client IP and avoids an extra hop, but nodes without Pods receive no traffic.

  34. Question 34. Which field in an Ingress configures HTTPS using a certificate stored in a Secret?

    1. spec.rules.http.paths.pathType
    2. metadata.annotations.ssl only
    3. spec.tls with hosts and secretName
    4. spec.defaultBackend.service
    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.

  35. Question 35. What does pathType: Prefix mean in an Ingress rule?

    1. The path matches the given prefix, split by slashes
    2. The path must match exactly
    3. The path uses regular expressions
    4. The rule applies to all hosts
    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.

  36. Question 36. How many NetworkPolicies can select the same Pod?

    1. Only one; the newest overrides older ones
    2. Many; their allowed traffic is combined
    3. Only two, one for ingress and one for egress
    4. None; policies select namespaces only
    Show answer

    Answer: B. Many; their allowed traffic is combined

    NetworkPolicies are additive. Traffic is allowed if any policy allows it.

  37. Question 37. Which component assigns IP addresses to Pods?

    1. The kube-scheduler, when it binds the Pod
    2. The CNI plugin, when the Pod's sandbox is created
    3. CoreDNS, when the Pod first sends a query
    4. The API server's admission controller
    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.

  38. Question 38. What is the default range for NodePort Services?

    1. 30000–32767
    2. 1–1024
    3. 8000–9000
    4. 49152–65535
    Show answer

    Answer: A. 30000–32767

    The range can be changed with the API server's --service-node-port-range flag.

  39. Question 39. A Service's ClusterIP responds, but only some requests fail. Which check is MOST useful?

    1. Whether the node's swap is enabled
    2. Whether some backend Pods are unhealthy
    3. Whether the Helm version is current
    4. Whether the etcd snapshot is recent
    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.