Bird
Raised Fist0
Kubernetesdevops~5 mins

Endpoints and endpoint slices in Kubernetes - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you run applications in Kubernetes, you often need to connect services to the right pods. Endpoints and endpoint slices help Kubernetes keep track of which pods belong to a service, so traffic goes to the right places.
When you want to see which pods are connected to a service in your cluster.
When you need to debug why a service is not routing traffic correctly.
When you want to understand how Kubernetes manages network connections between services and pods.
When you want to optimize network performance by using endpoint slices for large services.
When you want to monitor or troubleshoot service discovery in your Kubernetes cluster.
Commands
This command lists all the endpoints in the current namespace. Endpoints show which pods are linked to each service.
Terminal
kubectl get endpoints
Expected OutputExpected
NAME ENDPOINTS AGE kubernetes 10.96.0.1:443 10d
This command lists all endpoint slices in the current namespace. Endpoint slices are a newer, scalable way to track service endpoints.
Terminal
kubectl get endpointslices
Expected OutputExpected
NAME ADDRESSTYPE PORTS ENDPOINTS AGE kubernetes-abc123 IPv4 443 10.96.0.1 10d
This command shows detailed information about the endpoints for the 'kubernetes' service, including the IP addresses and ports of pods.
Terminal
kubectl describe endpoints kubernetes
Expected OutputExpected
Name: kubernetes Namespace: default Endpoints: 10.96.0.1:443 Age: 10d
This command shows detailed information about a specific endpoint slice, including addresses and ports it covers.
Terminal
kubectl describe endpointslice kubernetes-abc123
Expected OutputExpected
Name: kubernetes-abc123 Namespace: default AddressType: IPv4 Ports: Name: https Port: 443 Endpoints: 10.96.0.1 Age: 10d
Key Concept

Endpoints and endpoint slices map services to the pods that serve them, enabling Kubernetes to route traffic correctly.

Common Mistakes
Trying to edit endpoints directly to change service pods.
Endpoints are managed automatically by Kubernetes and manual edits will be overwritten.
Change the service selector or pod labels to update which pods belong to a service.
Ignoring endpoint slices and only using endpoints for large services.
Endpoints can become inefficient and slow with many pods; endpoint slices scale better.
Use endpoint slices for services with many pods to improve performance.
Summary
Use 'kubectl get endpoints' to see which pods are linked to services.
Use 'kubectl get endpointslices' to view scalable endpoint information.
Describe endpoints or endpoint slices to get detailed pod IPs and ports.

Practice

(1/5)
1. What is the primary purpose of Kubernetes Endpoints?
easy
A. To list the IP addresses of pods behind a service
B. To store configuration data for pods
C. To manage persistent storage volumes
D. To schedule pods on nodes

Solution

  1. Step 1: Understand the role of Endpoints in Kubernetes

    Endpoints represent the IP addresses of pods that a service routes traffic to.
  2. Step 2: Differentiate Endpoints from other Kubernetes objects

    Endpoints do not manage storage, scheduling, or configuration; they only list pod IPs behind a service.
  3. Final Answer:

    To list the IP addresses of pods behind a service -> Option A
  4. Quick Check:

    Endpoints = Pod IP list [OK]
Hint: Endpoints show pod IPs for services [OK]
Common Mistakes:
  • Confusing Endpoints with ConfigMaps
  • Thinking Endpoints manage storage
  • Assuming Endpoints schedule pods
2. Which kubectl command correctly lists EndpointSlices in the default namespace?
easy
A. kubectl describe endpointslices
B. kubectl get endpointslices -n default
C. kubectl get endpointslices
D. kubectl get endpoints -n default

Solution

  1. Step 1: Identify the correct resource name for EndpointSlices

    The resource name is 'endpointslices' (all lowercase, plural).
  2. Step 2: Use kubectl get with namespace option

    To list EndpointSlices in the default namespace, use 'kubectl get endpointslices -n default'.
  3. Final Answer:

    kubectl get endpointslices -n default -> Option B
  4. Quick Check:

    Correct resource and namespace flag = kubectl get endpointslices -n default [OK]
Hint: Use 'kubectl get endpointslices -n default' to list EndpointSlices [OK]
Common Mistakes:
  • Omitting the namespace flag when needed
  • Using 'endpoints' instead of 'endpointslices'
  • Using describe instead of get for listing
3. Given the following command output, what does it indicate about the service 'webapp'?
kubectl get endpoints webapp
NAME     ENDPOINTS           AGE
webapp   10.1.2.3:80,10.1.2.4:80   5m
medium
A. The service 'webapp' is using EndpointSlices instead of Endpoints
B. The service 'webapp' is not connected to any pods
C. The service 'webapp' has pods but no ports exposed
D. The service 'webapp' has two pods with IPs 10.1.2.3 and 10.1.2.4 serving on port 80

Solution

  1. Step 1: Analyze the 'kubectl get endpoints' output

    The output shows two IP addresses with port 80 listed under ENDPOINTS for 'webapp'.
  2. Step 2: Interpret the meaning of listed endpoints

    This means the service routes traffic to two pods at IPs 10.1.2.3 and 10.1.2.4 on port 80.
  3. Final Answer:

    The service 'webapp' has two pods with IPs 10.1.2.3 and 10.1.2.4 serving on port 80 -> Option D
  4. Quick Check:

    Endpoints list pod IPs and ports = The service 'webapp' has two pods with IPs 10.1.2.3 and 10.1.2.4 serving on port 80 [OK]
Hint: Endpoints output shows pod IPs and ports behind service [OK]
Common Mistakes:
  • Assuming no pods are connected when endpoints are listed
  • Confusing EndpointSlices with Endpoints output
  • Ignoring port numbers in the output
4. You run kubectl get endpointslices but see no output, even though your service has pods running. What is a likely cause?
medium
A. Pods are not running on any node
B. EndpointSlices feature is disabled in the cluster
C. The service has no selector labels
D. kubectl command is misspelled

Solution

  1. Step 1: Recall when EndpointSlices are created

    EndpointSlices are created only for services with selectors that match ready pods, generating endpoints.
  2. Step 2: Identify cause of empty output

    No selector labels means no automatic endpoints/EndpointSlices, resulting in no output (empty list). Feature disabled would error, not empty list.
  3. Final Answer:

    The service has no selector labels -> Option C
  4. Quick Check:

    No service selector = no EndpointSlices [OK]
Hint: No EndpointSlices despite pods? Check service selector matches pod labels [OK]
Common Mistakes:
  • Assuming feature disabled (causes API error, not empty list)
  • Thinking pods not running (contradicts premise)
  • Blaming kubectl misspelling
5. How do EndpointSlices improve Kubernetes service scalability compared to Endpoints?
hard
A. By splitting endpoints into smaller groups to reduce load on the API server
B. By caching pod IPs locally on each node
C. By replacing services with direct pod IP access
D. By encrypting endpoint data for security

Solution

  1. Step 1: Understand the limitation of Endpoints with many pods

    Endpoints list all pod IPs in one object, which can become large and heavy to manage.
  2. Step 2: Explain how EndpointSlices address this

    EndpointSlices split the endpoints into smaller chunks, reducing load on the API server and improving performance.
  3. Final Answer:

    By splitting endpoints into smaller groups to reduce load on the API server -> Option A
  4. Quick Check:

    EndpointSlices split endpoints for scalability [OK]
Hint: EndpointSlices split endpoints to reduce API load [OK]
Common Mistakes:
  • Thinking EndpointSlices cache IPs locally
  • Believing EndpointSlices replace services
  • Assuming EndpointSlices encrypt data
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard