1
1
---
2
2
reviewers :
3
3
- freehan
4
- title : Endpoint Slices
4
+ title : EndpointSlices
5
5
feature :
6
- title : Endpoint Slices
6
+ title : EndpointSlices
7
7
description : >
8
8
Scalable tracking of network endpoints in a Kubernetes cluster.
9
9
@@ -16,21 +16,22 @@ weight: 10
16
16
17
17
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
18
18
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
20
20
Kubernetes cluster. They offer a more scalable and extensible alternative to
21
21
Endpoints.
22
22
23
23
{{% /capture %}}
24
24
25
25
{{% capture body %}}
26
26
27
- ## Endpoint Slice resources {#endpointslice-resource}
27
+ ## EndpointSlice resources {#endpointslice-resource}
28
28
29
29
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.
34
35
35
36
As an example, here's a sample EndpointSlice resource for the ` example `
36
37
Kubernetes Service.
@@ -58,22 +59,110 @@ endpoints:
58
59
topology.kubernetes.io/zone : us-west2-a
59
60
` ` `
60
61
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
63
64
with Endpoints and Services and have similar performance.
64
65
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
66
67
how to route internal traffic. When enabled, they should provide a performance
67
68
improvement for services with large numbers of endpoints.
68
69
69
- ## Address Types
70
+ ### Address Types
70
71
71
72
EndpointSlices support three address types:
72
73
73
74
* IPv4
74
75
* IPv6
75
76
* FQDN (Fully Qualified Domain Name)
76
77
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
+
77
166
# # Motivation
78
167
79
168
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
86
175
resource, those resources could get quite large. That affected the performance
87
176
of Kubernetes components (notably the master control plane) and resulted in
88
177
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
90
179
platform for additional features such as topological routing.
91
180
92
181
{{% /capture %}}
93
182
94
183
{{% capture whatsnext %}}
95
184
96
- * [Enabling Endpoint Slices ](/docs/tasks/administer-cluster/enabling-endpointslices)
185
+ * [Enabling EndpointSlices ](/docs/tasks/administer-cluster/enabling-endpointslices)
97
186
* Read [Connecting Applications with Services](/docs/concepts/services-networking/connect-applications-service/)
98
187
99
188
{{% /capture %}}
0 commit comments