Courseiva
Services and Networking →mediumMultiple Choice

CKA Services and Networking Practice Question

Which of the following commands can be used to check the endpoints of a service named 'my-service'?

⚠ Common exam trap

It's easy for candidates to confuse the `kubectl describe svc` command (which shows endpoints in its output) with a non-existent `--show-endpoints` flag, or assume that the service YAML contains the resolved endpoint IPs.

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

✓

kubectl get endpoints my-service

The `kubectl get endpoints my-service` command directly retrieves the Endpoints object associated with the service, which lists the IP addresses and ports of the pods that match the service's selector. This is the standard and most direct way to check the active endpoints for a service in Kubernetes.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    kubectl get endpoints my-service

    Why this is correct

    This command queries the Endpoints API object that Kubernetes maintains for a Service. The endpoints controller watches the Service's pod selector and updates this object with the current IPs and ports of ready backing pods, so `kubectl get endpoints my-service` directly lists the live backend addresses that the Service routes to.

  • ✗

    kubectl get pod my-service

    Why it's wrong here

    This command treats `my-service` as a Pod name, but a Service and a Pod are distinct resource types in different API groups (v1 Service vs. v1 Pod). Unless a Pod literally labeled with that name exists, kubectl returns a NotFound error, and even if it existed it would show one Pod's details rather than the aggregated set of backend endpoints for the Service.

  • ✗

    kubectl get service my-service -o yaml

    Why it's wrong here

    Fetching the Service with `-o yaml` returns the Service object's full manifest, including spec (selector, ports) and status, but Service status does not contain the resolved backend IPs. The backend list is stored in a separate Endpoints resource, so YAML output of the Service alone will not show the actual pod IP:port pairs that the Service routes to.

  • ✗

    kubectl get svc my-service --show-endpoints

    Why it's wrong here

    The `--show-endpoints` flag does not exist for `kubectl get svc`; it is not a valid kubectl global or resource-level flag. The `svc` shorthand only supports standard get options such as `-o`, `-n`, or `--label-columns`. To inspect the endpoints, you must explicitly query a separate resource: `kubectl get endpoints my-service`.

About these practice questions

This CKA question is part of Courseiva's 726-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 →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CKA 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 CKA exam.