@@ -19,8 +19,7 @@ description: >-
19
19
{{< feature-state for_k8s_version="v1.21" state="stable" >}}
20
20
21
21
Kubernetes' _ EndpointSlice_ API provides a way to track network endpoints
22
- within a Kubernetes cluster. EndpointSlices offer a more scalable and extensible
23
- alternative to [ Endpoints] ( /docs/concepts/services-networking/service/#endpoints ) .
22
+ within a Kubernetes cluster.
24
23
25
24
<!-- body -->
26
25
@@ -31,8 +30,8 @@ endpoints. The control plane automatically creates EndpointSlices
31
30
for any Kubernetes Service that has a {{< glossary_tooltip text="selector"
32
31
term_id="selector" >}} specified. These EndpointSlices include
33
32
references to all the Pods that match the Service selector. EndpointSlices group
34
- network endpoints together by unique combinations of protocol, port number, and
35
- Service name.
33
+ network endpoints together by unique combinations of IP family, protocol,
34
+ port number, and Service name.
36
35
The name of a EndpointSlice object must be a valid
37
36
[ DNS subdomain name] ( /docs/concepts/overview/working-with-objects/names#dns-subdomain-names ) .
38
37
@@ -67,17 +66,16 @@ more than 100 endpoints each. You can configure this with the
67
66
{{< glossary_tooltip text="kube-controller-manager" term_id="kube-controller-manager" >}}
68
67
flag, up to a maximum of 1000.
69
68
70
- EndpointSlices can act as the source of truth for
69
+ EndpointSlices act as the source of truth for
71
70
{{< glossary_tooltip term_id="kube-proxy" text="kube-proxy" >}} when it comes to
72
71
how to route internal traffic.
73
72
74
73
# ## Address types
75
74
76
- EndpointSlices support three address types :
75
+ EndpointSlices support two address types :
77
76
78
77
* IPv4
79
78
* IPv6
80
- * FQDN (Fully Qualified Domain Name)
81
79
82
80
Each `EndpointSlice` object represents a specific IP address type. If you have
83
81
a Service that is available via IPv4 and IPv6, there will be at least two
@@ -86,42 +84,37 @@ a Service that is available via IPv4 and IPv6, there will be at least two
86
84
# ## Conditions
87
85
88
86
The EndpointSlice API stores conditions about endpoints that may be useful for consumers.
89
- The three conditions are `ready`, `serving`, and `terminating`.
90
-
91
- # ### Ready
92
-
93
- ` ready` is a condition that maps to a Pod's `Ready` condition. A running Pod with the `Ready`
94
- condition set to `True` should have this EndpointSlice condition also set to `true`. For
95
- compatibility reasons, `ready` is NEVER `true` when a Pod is terminating. Consumers should refer
96
- to the `serving` condition to inspect the readiness of terminating Pods. The only exception to
97
- this rule is for Services with `spec.publishNotReadyAddresses` set to `true`. Endpoints for these
98
- Services will always have the `ready` condition set to `true`.
87
+ The three conditions are `serving`, `terminating`, and `ready`.
99
88
100
89
# ### Serving
101
90
102
91
{{< feature-state for_k8s_version="v1.26" state="stable" >}}
103
92
104
- The `serving` condition is almost identical to the `ready` condition. The difference is that
105
- consumers of the EndpointSlice API should check the `serving` condition if they care about pod readiness while
106
- the pod is also terminating .
93
+ The `serving` condition indicates that the endpoint is currently serving responses, and
94
+ so it should be used as a target for Service traffic. For endpoints backed by a Pod, this
95
+ maps to the Pod's `Ready` condition .
107
96
108
- {{< note >}}
97
+ # ### Terminating
109
98
110
- Although `serving` is almost identical to `ready`, it was added to prevent breaking the existing meaning
111
- of `ready`. It may be unexpected for existing clients if `ready` could be `true` for terminating
112
- endpoints, since historically terminating endpoints were never included in the Endpoints or
113
- EndpointSlice API to begin with. For this reason, `ready` is _always_ `false` for terminating
114
- endpoints, and a new condition `serving` was added in v1.20 so that clients can track readiness
115
- for terminating pods independent of the existing semantics for `ready`.
99
+ {{< feature-state for_k8s_version="v1.26" state="stable" >}}
116
100
117
- {{< /note >}}
101
+ The `terminating` condition indicates that the endpoint is
102
+ terminating. For endpoints backed by a Pod, this condition is set when
103
+ the Pod is first deleted (that is, when it receives a deletion
104
+ timestamp, but most likely before the Pod's containers exit).
118
105
119
- # ### Terminating
106
+ Service proxies will normally ignore endpoints that are `terminating`,
107
+ but they may route traffic to endpoints that are both `serving` and
108
+ ` terminating` if all available endpoints are `terminating`. (This
109
+ helps to ensure that no Service traffic is lost during rolling updates
110
+ of the underlying Pods.)
120
111
121
- {{< feature-state for_k8s_version="v1.22" state="beta" >}}
112
+ # ### Ready
122
113
123
- ` Terminating` is a condition that indicates whether an endpoint is terminating.
124
- For pods, this is any pod that has a deletion timestamp set.
114
+ The `ready` condition is essentially a shortcut for checking
115
+ " `serving` and not `terminating`" (though it will also always be
116
+ ` true` for Services with `spec.publishNotReadyAddresses` set to
117
+ ` true` ).
125
118
126
119
# ## Topology information {#topology}
127
120
@@ -133,18 +126,6 @@ per endpoint fields on EndpointSlices:
133
126
* `nodeName` - The name of the Node this endpoint is on.
134
127
* `zone` - The zone this endpoint is in.
135
128
136
- {{< note >}}
137
- In the v1 API, the per endpoint `topology` was effectively removed in favor of
138
- the dedicated fields `nodeName` and `zone`.
139
-
140
- Setting arbitrary topology fields on the `endpoint` field of an `EndpointSlice`
141
- resource has been deprecated and is not supported in the v1 API.
142
- Instead, the v1 API supports setting individual `nodeName` and `zone` fields.
143
- These fields are automatically translated between API versions. For example, the
144
- value of the `"topology.kubernetes.io/zone"` key in the `topology` field in
145
- the v1beta1 API is accessible as the `zone` field in the v1 API.
146
- {{< /note >}}
147
-
148
129
# ## Management
149
130
150
131
Most often, the control plane (specifically, the endpoint slice
@@ -169,34 +150,12 @@ slice object tracks endpoints for. This ownership is indicated by an owner
169
150
reference on each EndpointSlice as well as a `kubernetes.io/service-name`
170
151
label that enables simple lookups of all EndpointSlices belonging to a Service.
171
152
172
- # ## EndpointSlice mirroring
173
-
174
- In some cases, applications create custom Endpoints resources. To ensure that
175
- these applications do not need to concurrently write to both Endpoints and
176
- EndpointSlice resources, the cluster's control plane mirrors most Endpoints
177
- resources to corresponding EndpointSlices.
178
-
179
- The control plane mirrors Endpoints resources unless :
180
-
181
- * the Endpoints resource has a `endpointslice.kubernetes.io/skip-mirror` label
182
- set to `true`.
183
- * the Endpoints resource has a `control-plane.alpha.kubernetes.io/leader`
184
- annotation.
185
- * the corresponding Service resource does not exist.
186
- * the corresponding Service resource has a non-nil selector.
187
-
188
- Individual Endpoints resources may translate into multiple EndpointSlices. This
189
- will occur if an Endpoints resource has multiple subsets or includes endpoints
190
- with multiple IP families (IPv4 and IPv6). A maximum of 1000 addresses per
191
- subset will be mirrored to EndpointSlices.
192
-
193
153
# ## Distribution of EndpointSlices
194
154
195
155
Each EndpointSlice has a set of ports that applies to all endpoints within the
196
156
resource. When named ports are used for a Service, Pods may end up with
197
157
different target port numbers for the same named port, requiring different
198
- EndpointSlices. This is similar to the logic behind how subsets are grouped
199
- with Endpoints.
158
+ EndpointSlices.
200
159
201
160
The control plane tries to fill EndpointSlices as full as possible, but does not
202
161
actively rebalance them. The logic is fairly straightforward :
@@ -244,34 +203,36 @@ You can find a reference implementation for how to perform this endpoint aggrega
244
203
and deduplication as part of the `EndpointSliceCache` code within `kube-proxy`.
245
204
{{< /note >}}
246
205
247
- # # Comparison with Endpoints {#motivation}
248
-
249
- The original Endpoints API provided a simple and straightforward way of
250
- tracking network endpoints in Kubernetes. As Kubernetes clusters
251
- and {{< glossary_tooltip text="Services" term_id="service" >}} grew to handle
252
- more traffic and to send more traffic to more backend Pods, the
253
- limitations of that original API became more visible.
254
- Most notably, those included challenges with scaling to larger numbers of
255
- network endpoints.
256
-
257
- Since all network endpoints for a Service were stored in a single Endpoints
258
- object, those Endpoints objects could get quite large. For Services that stayed
259
- stable (the same set of endpoints over a long period of time) the impact was
260
- less noticeable; even then, some use cases of Kubernetes weren't well served.
261
-
262
- When a Service had a lot of backend endpoints and the workload was either
263
- scaling frequently, or rolling out new changes frequently, each update to
264
- the single Endpoints object for that Service meant a lot of traffic between
265
- Kubernetes cluster components (within the control plane, and also between
266
- nodes and the API server). This extra traffic also had a cost in terms of
267
- CPU use.
268
-
269
- With EndpointSlices, adding or removing a single Pod triggers the same _number_
270
- of updates to clients that are watching for changes, but the size of those
271
- update message is much smaller at large scale.
272
-
273
- EndpointSlices also enabled innovation around new features such dual-stack
274
- networking and topology-aware routing.
206
+ # ## EndpointSlice mirroring
207
+
208
+ {{< feature-state for_k8s_version="v1.33" state="deprecated" >}}
209
+
210
+ The EndpointSlice API is a replacement for the older Endpoints API. To
211
+ preserve compatibility with older controllers and user workloads that
212
+ expect {{<glossary_tooltip term_id="kube-proxy" text="kube-proxy">}}
213
+ to route traffic based on Endpoints resources, the cluster's control
214
+ plane mirrors most user-created Endpoints resources to corresponding
215
+ EndpointSlices.
216
+
217
+ (However, this feature, like the rest of the Endpoints API, is
218
+ deprecated. Users who manually specify endpoints for selectorless
219
+ Services should do so by creating EndpointSlice resources directly,
220
+ rather than by creating Endpoints resources and allowing them to be
221
+ mirrored.)
222
+
223
+ The control plane mirrors Endpoints resources unless :
224
+
225
+ * the Endpoints resource has a `endpointslice.kubernetes.io/skip-mirror` label
226
+ set to `true`.
227
+ * the Endpoints resource has a `control-plane.alpha.kubernetes.io/leader`
228
+ annotation.
229
+ * the corresponding Service resource does not exist.
230
+ * the corresponding Service resource has a non-nil selector.
231
+
232
+ Individual Endpoints resources may translate into multiple EndpointSlices. This
233
+ will occur if an Endpoints resource has multiple subsets or includes endpoints
234
+ with multiple IP families (IPv4 and IPv6). A maximum of 1000 addresses per
235
+ subset will be mirrored to EndpointSlices.
275
236
276
237
# # {{% heading "whatsnext" %}}
277
238
0 commit comments