Bird
Raised Fist0
Kubernetesdevops~10 mins

Endpoints and endpoint slices in Kubernetes - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Endpoints and endpoint slices
Service Created
↓
Pods Selected by Service
↓
Endpoints Created
↓
Endpoint Slices Created
↓
Clients Query Service
↓
Clients Get Endpoint Slices
↓
Clients Connect to Pod IPs
This flow shows how a Kubernetes Service selects pods, creates endpoints, then groups them into endpoint slices for clients to connect.
Execution Sample
Kubernetes
kubectl get endpoints my-service
kubectl get endpointslices -l kubernetes.io/service-name=my-service
These commands show the endpoints and endpoint slices for a service named 'my-service'.
Process Table
StepActionResource Created/UpdatedDetailsResult
1Create ServiceService 'my-service'Selector: app=webService created with selector
2Pods labeled app=web startPodsPod IPs: 10.0.0.1, 10.0.0.2Pods running and labeled
3Service controller finds matching podsEndpointsEndpoints list IPs: 10.0.0.1, 10.0.0.2Endpoints resource created
4Endpoint Slices createdEndpointSlicesSlices group IPs (max 100 per slice)EndpointSlices resource created
5Client queries ServiceDNS lookupService IP resolvedClient gets endpoint slices info
6Client connects to pod IPsNetwork connectionsConnects to 10.0.0.1 or 10.0.0.2Traffic routed to pods
7Pod 10.0.0.2 removedEndpoints updatedEndpoints now only 10.0.0.1Endpoints and slices updated
8Client queries againDNS lookupService IP resolvedClient gets updated endpoint slices
9Client connects to remaining podNetwork connectionsConnects to 10.0.0.1Traffic routed correctly
10No more matching podsEndpoints emptyNo IPs listedService has no endpoints
11Client queriesDNS lookupService IP resolvedClient gets empty endpoint slices
12Client connection failsNetwork connectionsNo pods to connectConnection fails or retries
💡 Execution stops when no pods match the service selector, so endpoints and endpoint slices are empty.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 7After Step 10Final
Pods with label app=webNone10.0.0.1, 10.0.0.210.0.0.1, 10.0.0.210.0.0.1, 10.0.0.210.0.0.1NoneNone
Endpoints IPsNoneNone10.0.0.1, 10.0.0.210.0.0.1, 10.0.0.210.0.0.1NoneNone
Endpoint Slices IPsNoneNoneNone10.0.0.1, 10.0.0.210.0.0.1NoneNone
Key Moments - 3 Insights
Why do endpoint slices exist if endpoints already list pod IPs?
Endpoint slices split endpoints into smaller groups for scalability and efficiency, as shown in step 4 where slices group IPs instead of one big list.
What happens to endpoints and endpoint slices when a pod is removed?
As in step 7, the pod IP is removed from endpoints and endpoint slices are updated to reflect the current pods.
Why does the client get empty endpoint slices sometimes?
When no pods match the service selector (step 10), endpoints and endpoint slices are empty, so clients receive no pod IPs to connect.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table at step 3. What IPs are listed in the endpoints?
ANo IPs listed
B10.0.0.1 and 10.0.0.2
COnly 10.0.0.1
D10.0.0.3
💡 Hint
Check the 'Endpoints' column in step 3 of the execution table.
At which step does the endpoints list update to remove a pod IP?
AStep 7
BStep 4
CStep 10
DStep 2
💡 Hint
Look for the step mentioning pod removal and endpoints update.
If a new pod with IP 10.0.0.3 is added matching the service selector, what changes in the variable tracker after step 2?
AEndpoints remain unchanged
BEndpoint slices become empty
CPods list includes 10.0.0.1, 10.0.0.2, 10.0.0.3
DPods list is empty
💡 Hint
Check the 'Pods with label app=web' row in variable tracker after step 2.
Concept Snapshot
Kubernetes Services select pods by labels.
Endpoints list pod IPs matching the service.
Endpoint Slices group endpoints for scalability.
Clients query endpoint slices to connect to pods.
Endpoint slices update dynamically as pods change.
Full Transcript
In Kubernetes, when you create a Service, it selects pods using labels. The system creates an Endpoints resource listing the IPs of those pods. To improve scalability, Kubernetes groups these endpoints into Endpoint Slices, each holding a subset of pod IPs. Clients querying the Service get these endpoint slices to know where to send traffic. When pods are added or removed, endpoints and endpoint slices update accordingly. If no pods match, endpoints and slices are empty, so clients cannot connect. This flow ensures efficient and scalable routing of traffic to pods.

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