Skip to content

Commit c192154

Browse files
robscottk8s-ci-robot
authored andcommitted
Providing more detail on EndpointSlice implementation (kubernetes#18343)
1 parent f41978d commit c192154

File tree

4 files changed

+144
-37
lines changed

4 files changed

+144
-37
lines changed

content/en/docs/concepts/services-networking/endpoint-slices.md

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
reviewers:
33
- freehan
4-
title: Endpoint Slices
4+
title: EndpointSlices
55
feature:
6-
title: Endpoint Slices
6+
title: EndpointSlices
77
description: >
88
Scalable tracking of network endpoints in a Kubernetes cluster.
99
@@ -16,21 +16,22 @@ weight: 10
1616

1717
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
1818

19-
_Endpoint Slices_ provide a simple way to track network endpoints within a
19+
_EndpointSlices_ provide a simple way to track network endpoints within a
2020
Kubernetes cluster. They offer a more scalable and extensible alternative to
2121
Endpoints.
2222

2323
{{% /capture %}}
2424

2525
{{% capture body %}}
2626

27-
## Endpoint Slice resources {#endpointslice-resource}
27+
## EndpointSlice resources {#endpointslice-resource}
2828

2929
In Kubernetes, an EndpointSlice contains references to a set of network
30-
endpoints. The EndpointSlice controller automatically creates Endpoint Slices
31-
for a Kubernetes Service when a selector is specified. These Endpoint Slices
32-
will include references to any Pods that match the Service selector. Endpoint
33-
Slices group network endpoints together by unique Service and Port combinations.
30+
endpoints. The EndpointSlice controller automatically creates EndpointSlices
31+
for a Kubernetes Service when a {{< glossary_tooltip text="selector"
32+
term_id="selector" >}} is specified. These EndpointSlices will include
33+
references to any Pods that match the Service selector. EndpointSlices group
34+
network endpoints together by unique Service and Port combinations.
3435

3536
As an example, here's a sample EndpointSlice resource for the `example`
3637
Kubernetes Service.
@@ -58,22 +59,110 @@ endpoints:
5859
topology.kubernetes.io/zone: us-west2-a
5960
```
6061
61-
By default, Endpoint Slices managed by the EndpointSlice controller will have no
62-
more than 100 endpoints each. Below this scale, Endpoint Slices should map 1:1
62+
By default, EndpointSlices managed by the EndpointSlice controller will have no
63+
more than 100 endpoints each. Below this scale, EndpointSlices should map 1:1
6364
with Endpoints and Services and have similar performance.
6465
65-
Endpoint Slices can act as the source of truth for kube-proxy when it comes to
66+
EndpointSlices can act as the source of truth for kube-proxy when it comes to
6667
how to route internal traffic. When enabled, they should provide a performance
6768
improvement for services with large numbers of endpoints.
6869
69-
## Address Types
70+
### Address Types
7071
7172
EndpointSlices support three address types:
7273
7374
* IPv4
7475
* IPv6
7576
* FQDN (Fully Qualified Domain Name)
7677
78+
### Topology
79+
80+
Each endpoint within an EndpointSlice can contain relevant topology information.
81+
This is used to indicate where an endpoint is, containing information about the
82+
corresponding Node, zone, and region. When the values are available, the
83+
following Topology labels will be set by the EndpointSlice controller:
84+
85+
* `kubernetes.io/hostname` - The name of the Node this endpoint is on.
86+
* `topology.kubernetes.io/zone` - The zone this endpoint is in.
87+
* `topology.kubernetes.io/region` - The region this endpoint is in.
88+
89+
The values of these labels are derived from resources associated with each
90+
endpoint in a slice. The hostname label represents the value of the NodeName
91+
field on the corresponding Pod. The zone and region labels represent the value
92+
of the labels with the same names on the corresponding Node.
93+
94+
### Management
95+
96+
By default, EndpointSlices are created and managed by the EndpointSlice
97+
controller. There are a variety of other use cases for EndpointSlices, such as
98+
service mesh implementations, that could result in other entities or controllers
99+
managing additional sets of EndpointSlices. To ensure that multiple entities can
100+
manage EndpointSlices without interfering with each other, a
101+
`endpointslice.kubernetes.io/managed-by` label is used to indicate the entity
102+
managing an EndpointSlice. The EndpointSlice controller sets
103+
`endpointslice-controller.k8s.io` as the value for this label on all
104+
EndpointSlices it manages. Other entities managing EndpointSlices should also
105+
set a unique value for this label.
106+
107+
### Ownership
108+
109+
In most use cases, EndpointSlices will be owned by the Service that it tracks
110+
endpoints for. This is indicated by an owner reference on each EndpointSlice as
111+
well as a `kubernetes.io/service-name` label that enables simple lookups of all
112+
EndpointSlices belonging to a Service.
113+
114+
## EndpointSlice Controller
115+
116+
The EndpointSlice controller watches Services and Pods to ensure corresponding
117+
EndpointSlices are up to date. The controller will manage EndpointSlices for
118+
every Service with a selector specified. These will represent the IPs of Pods
119+
matching the Service selector.
120+
121+
### Size of EndpointSlices
122+
123+
By default, EndpointSlices are limited to a size of 100 endpoints each. You can
124+
configure this with the `--max-endpoints-per-slice` {{< glossary_tooltip
125+
text="kube-controller-manager" term_id="kube-controller-manager" >}} flag up to
126+
a maximum of 1000.
127+
128+
### Distribution of EndpointSlices
129+
130+
Each EndpointSlice has a set of ports that applies to all endpoints within the
131+
resource. When named ports are used for a Service, Pods may end up with
132+
different target port numbers for the same named port, requiring different
133+
EndpointSlices. This is similar to the logic behind how subsets are grouped
134+
with Endpoints.
135+
136+
The controller tries to fill EndpointSlices as full as possible, but does not
137+
actively rebalance them. The logic of the controller is fairly straightforward:
138+
139+
1. Iterate through existing EndpointSlices, remove endpoints that are no longer
140+
desired and update matching endpoints that have changed.
141+
2. Iterate through EndpointSlices that have been modified in the first step and
142+
fill them up with any new endpoints needed.
143+
3. If there's still new endpoints left to add, try to fit them into a previously
144+
unchanged slice and/or create new ones.
145+
146+
Importantly, the third step prioritizes limiting EndpointSlice updates over a
147+
perfectly full distribution of EndpointSlices. As an example, if there are 10
148+
new endpoints to add and 2 EndpointSlices with room for 5 more endpoints each,
149+
this approach will create a new EndpointSlice instead of filling up the 2
150+
existing EndpointSlices. In other words, a single EndpointSlice creation is
151+
preferrable to multiple EndpointSlice updates.
152+
153+
With kube-proxy running on each Node and watching EndpointSlices, every change
154+
to an EndpointSlice becomes relatively expensive since it will be transmitted to
155+
every Node in the cluster. This approach is intended to limit the number of
156+
changes that need to be sent to every Node, even if it may result with multiple
157+
EndpointSlices that are not full.
158+
159+
In practice, this less than ideal distribution should be rare. Most changes
160+
processed by the EndpointSlice controller will be small enough to fit in an
161+
existing EndpointSlice, and if not, a new EndpointSlice is likely going to be
162+
necessary soon anyway. Rolling updates of Deployments also provide a natural
163+
repacking of EndpointSlices with all pods and their corresponding endpoints
164+
getting replaced.
165+
77166
## Motivation
78167

79168
The Endpoints API has provided a simple and straightforward way of
@@ -86,14 +175,14 @@ Since all network endpoints for a Service were stored in a single Endpoints
86175
resource, those resources could get quite large. That affected the performance
87176
of Kubernetes components (notably the master control plane) and resulted in
88177
significant amounts of network traffic and processing when Endpoints changed.
89-
Endpoint Slices help you mitigate those issues as well as provide an extensible
178+
EndpointSlices help you mitigate those issues as well as provide an extensible
90179
platform for additional features such as topological routing.
91180

92181
{{% /capture %}}
93182

94183
{{% capture whatsnext %}}
95184

96-
* [Enabling Endpoint Slices](/docs/tasks/administer-cluster/enabling-endpointslices)
185+
* [Enabling EndpointSlices](/docs/tasks/administer-cluster/enabling-endpointslices)
97186
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
98187

99188
{{% /capture %}}

content/en/docs/concepts/services-networking/service.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@ An ExternalName Service is a special case of Service that does not have
184184
selectors and uses DNS names instead. For more information, see the
185185
[ExternalName](#externalname) section later in this document.
186186

187-
### Endpoint Slices
187+
### EndpointSlices
188188
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
189189

190-
Endpoint Slices are an API resource that can provide a more scalable alternative
191-
to Endpoints. Although conceptually quite similar to Endpoints, Endpoint Slices
190+
EndpointSlices are an API resource that can provide a more scalable alternative
191+
to Endpoints. Although conceptually quite similar to Endpoints, EndpointSlices
192192
allow for distributing network endpoints across multiple resources. By default,
193-
an Endpoint Slice is considered "full" once it reaches 100 endpoints, at which
194-
point additional Endpoint Slices will be created to store any additional
193+
an EndpointSlice is considered "full" once it reaches 100 endpoints, at which
194+
point additional EndpointSlices will be created to store any additional
195195
endpoints.
196196

197-
Endpoint Slices provide additional attributes and functionality which is
198-
described in detail in [Endpoint Slices](/docs/concepts/services-networking/endpoint-slices/).
197+
EndpointSlices provide additional attributes and functionality which is
198+
described in detail in [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/).
199199

200200
## Virtual IPs and service proxies
201201

@@ -1196,6 +1196,6 @@ which encompass the current ClusterIP, NodePort, and LoadBalancer modes and more
11961196
11971197
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
11981198
* Read about [Ingress](/docs/concepts/services-networking/ingress/)
1199-
* Read about [Endpoint Slices](/docs/concepts/services-networking/endpoint-slices/)
1199+
* Read about [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
12001200
12011201
{{% /capture %}}

content/en/docs/reference/glossary/endpoint-slice.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Endpoint Slice
2+
title: EndpointSlice
33
id: endpoint-slice
44
date: 2018-04-12
55
full_link: /docs/concepts/services-networking/endpoint-slices/

content/en/docs/tasks/administer-cluster/enabling-endpointslices.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
reviewers:
33
- bowei
44
- freehan
5-
title: Enabling Endpoint Slices
5+
title: Enabling EndpointSlices
66
content_template: templates/task
77
---
88

99
{{% capture overview %}}
10-
This page provides an overview of enabling Endpoint Slices in Kubernetes.
10+
This page provides an overview of enabling EndpointSlices in Kubernetes.
1111
{{% /capture %}}
1212

1313

@@ -19,30 +19,48 @@ This page provides an overview of enabling Endpoint Slices in Kubernetes.
1919

2020
## Introduction
2121

22-
Endpoint Slices provide a scalable and extensible alternative to Endpoints in
22+
EndpointSlices provide a scalable and extensible alternative to Endpoints in
2323
Kubernetes. They build on top of the base of functionality provided by Endpoints
2424
and extend that in a scalable way. When Services have a large number (>100) of
25-
network endpoints, they will be split into multiple smaller Endpoint Slice
25+
network endpoints, they will be split into multiple smaller EndpointSlice
2626
resources instead of a single large Endpoints resource.
2727

28-
## Enabling Endpoint Slices
28+
## Enabling EndpointSlices
2929

3030
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
3131

3232
{{< note >}}
33-
Although Endpoint Slices may eventually replace Endpoints, many Kubernetes
34-
components still rely on Endpoints. For now, enabling Endpoint Slices should be
33+
Although EndpointSlices may eventually replace Endpoints, many Kubernetes
34+
components still rely on Endpoints. For now, enabling EndpointSlices should be
3535
seen as an addition to Endpoints in a cluster, not a replacement for them.
3636
{{< /note >}}
3737

38-
As an alpha feature, Endpoint Slices are not enabled by default in Kubernetes.
39-
To enable them, the EndpointSlice feature gate will need to be enabled
40-
(`--feature-gates=EndpointSlice=true`).
38+
EndpointSlices are considered a beta feature, but only the API is enabled by
39+
default. Both the EndpointSlice controller and the usage of EndpointSlices by
40+
kube-proxy are not enabled by default.
4141

42-
## Using Endpoint Slices
42+
The EndpointSlice controller creates and manages EndpointSlices in a cluster.
43+
You can enable it with the `EndpointSlice` [feature
44+
gate](/docs/reference/command-line-tools-reference/feature-gates/) on the {{<
45+
glossary_tooltip text="kube-apiserver" term_id="kube-apiserver" >}} and {{<
46+
glossary_tooltip text="kube-controller-manager"
47+
term_id="kube-controller-manager" >}} (`--feature-gates=EndpointSlice=true`).
4348

44-
With Endpoint Slices fully enabled in your cluster, you should see corresponding
49+
For better scalability, you can also enable this feature gate on {{<
50+
glossary_tooltip text="kube-proxy" term_id="kube-proxy" >}} so EndpointSlices
51+
will be used as the data source instead of Endpoints.
52+
53+
## Using EndpointSlices
54+
55+
With EndpointSlices fully enabled in your cluster, you should see corresponding
4556
EndpointSlice resources for each Endpoints resource. In addition to supporting
46-
existing Endpoints functionality, Endpoint Slices should include new bits of
57+
existing Endpoints functionality, EndpointSlices should include new bits of
4758
information such as topology. They will allow for greater scalability and
48-
extensibility of network endpoints in your cluster.
59+
extensibility of network endpoints in your cluster.
60+
61+
{{% capture whatsnext %}}
62+
63+
* Read about [EndpointSlices](/docs/concepts/services-networking/endpoint-slices/)
64+
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
65+
66+
{{% /capture %}}

0 commit comments

Comments
 (0)