Courseiva
Services and NetworkingmediumMultiple ChoiceObjective-mapped

CKA Services and Networking Practice Question

Which kubectl command correctly retrieves the list of EndpointSlices for a Service named 'my-svc' in the 'default' namespace?

⚠ Common exam trap

Many exam-takers confuse the legacy `endpoints` resource with `endpointslice`, or assume that `kubectl get endpointslice my-svc` works like `kubectl get pods my-pod`, not realizing that EndpointSlices are not named after the Service and require a label selector to filter.

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 endpointslice -n default --selector=kubernetes.io/service-name=my-svc

EndpointSlices are the modern, scalable replacement for Endpoints, and they use a specific label `kubernetes.io/service-name` to associate them with a Service. The command `kubectl get endpointslice -n default --selector=kubernetes.io/service-name=my-svc` correctly filters EndpointSlices by that label, retrieving all slices belonging to 'my-svc'.

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-svc -n default

    Why it's wrong here

    The command queries the legacy Endpoints API (v1), which is a distinct resource from EndpointSlice. Although Endpoints historically stored a Service's IP:port lists, they are deprecated and provide a single monolithic object per Service, not the sharded, label-selectable list of EndpointSlice resources you want.

  • kubectl describe svc my-svc -n default

    Why it's wrong here

    Running kubectl describe on a Service displays only a human-readable summary, including an 'Endpoints' field derived from the underlying endpoint data, but it does not enumerate individual EndpointSlice objects or expose their topology, capacity, or conditions. It also cannot apply label selectors to filter slices. Therefore, this command does not correctly retrieve the list of EndpointSlices.

  • kubectl get endpointslice -n default --selector=kubernetes.io/service-name=my-svc

    Why this is correct

    The label selector kubernetes.io/service-name=my-svc is the standard label automatically applied by the EndpointSlice controller to each slice that belongs to the Service. Since a Service can have multiple EndpointSlices (sharded by address type, subsets, or topology), this selector collects all of them, which is exactly what the task requires. The kubectl get endpointslice command then lists every matching EndpointSlice object in the default namespace.

  • kubectl get endpointslices my-svc -n default

    Why it's wrong here

    Providing my-svc as a positional argument makes kubectl interpret it as an object name, so it attempts to return a single EndpointSlice literally named 'my-svc'. In practice, EndpointSlices receive auto-generated names with random suffixes, so this lookup will almost always fail with a NotFound error. The correct filter for Service membership is the --selector flag with the kubernetes.io/service-name label, not a resource name.

About these practice questions

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