Skip to content

Commit e26d59d

Browse files
fixup! fixup! fixup! fixup! fixup! fixup! Add KEP 4444: Routing Preference for Services
1 parent 7a18a06 commit e26d59d

File tree

1 file changed

+51
-67
lines changed
  • keps/sig-network/4444-service-routing-preference

1 file changed

+51
-67
lines changed

keps/sig-network/4444-service-routing-preference/README.md

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
- [Story 2](#story-2)
1515
- [Story 3](#story-3)
1616
- [Story 4](#story-4)
17-
- [Story 5](#story-5)
1817
- [Notes/Constraints/Caveats](#notesconstraintscaveats)
1918
- [Risks and Mitigations](#risks-and-mitigations)
2019
- [Design Details](#design-details)
2120
- [Standard Heuristic Implementation (kube-proxy dataplane)](#standard-heuristic-implementation-kube-proxy-dataplane)
22-
- [<code>Default</code> and <code>Spread</code>](#default-and-spread)
23-
- [<code>Zone</code>](#zone)
21+
- [<code>Default</code>](#default)
22+
- [<code>Close</code>](#close)
2423
- [Changes within kube-proxy](#changes-within-kube-proxy)
2524
- [Status Reporting](#status-reporting)
2625
- [Condition usage by other implementations](#condition-usage-by-other-implementations)
@@ -189,11 +188,6 @@ such a preference in future refinements.
189188
hints and preferences that implementations can consider when making routing
190189
decisions.
191190

192-
* **Mandatory and Uniform Implementation Support:** Kubernetes implementations
193-
are not required to support all standard heuristics (e.g., `Zone`, `Spread`).
194-
Even when standard heuristics are supported, their precise behavior and
195-
interpretation might vary across implementations.
196-
197191
* **Replacement of Traffic Policies:** The new field is complementary to
198192
`internalTrafficPolicy` and `externalTrafficPolicy`. It does not aim to
199193
substitute their role in enforcing strict traffic locality.
@@ -211,33 +205,28 @@ while making routing decisions. It does not offer strict routing guarantees.
211205

212206
The field will support the following initial values:
213207

214-
<<[UNRESOLVED Name for field values is under discussion]>>
215208

216209
* `Default`: Indicates no specific routing preference. The user delegates the
217210
routing decision to the implementation, allowing it to apply its best-effort
218211
strategy.
219-
* `Spread`: Encourages an equal distribution of traffic across
220-
endpoints, potentially spanning multiple zones (or regions).
221-
* `Zone`: Encourages routing traffic to endpoints within the same zone as
222-
the client. If no endpoints are available within the zone, traffic should be
223-
routed to other zones.
224-
225-
<<[/UNRESOLVED]>>
212+
* `Close`: Indicates a preference for routing traffic to endpoints that
213+
are topologically proximate to the client. The interpretation of
214+
"topologically proximate" may vary across implementations and could encompass
215+
endpoints within the same node, rack, zone, or even region.
226216

227-
Implementations are strongly encouraged to support the standard values. While
228-
some flexibility in interpretation is permitted, implementations should aim to
229-
align their behavior with the described intent of these preferences as closely
230-
as possible.
217+
Implementations SHOULD support the standard values. While some flexibility in
218+
interpretation is permitted, implementations should aim to align their behavior
219+
with the described intent of these preferences as closely as possible.
231220

232221
Implementations may support additional routing heuristics using values of the
233222
form `<domain>/<heuristicName>`. Heuristics without a domain prefix will be
234223
reserved for potential future standardization.
235224

236225
NOTE: Implementations reserve the right to refine the behavior associated with
237226
any heuristic, including standard heuristics. This means the behavior enabled
238-
by values such as `Default` or `Zone` might evolve over time, and some
227+
by values such as `Default` or `Close` might evolve over time, and some
239228
evolutions might interpret the heuristic goals slightly differently. For
240-
example, in the case of `Zone`, an implementation might initially route
229+
example, in the case of `Close`, an implementation might initially route
241230
traffic within the zone without considering endpoint overload, while a future
242231
refinement could introduce feedback mechanisms to detect overload and route
243232
traffic outside the zone when necessary, optimizing overall performance. The
@@ -257,10 +246,10 @@ NOTE: Implementations reserve the right to refine the behavior associated with
257246
implementation evolves. It may load balance across zones or regions.
258247

259248
#### Story 2
260-
* **Requirement:** I want my application to primarily receive traffic from
261-
endpoints within the same zone for performance or cost reasons. However,
262-
I want to avoid connection failures if no local endpoints are available.
263-
* **Solution:** Set `routingPreference: Zone`
249+
* **Requirement:** I want my application to primarily send traffic to endpoints
250+
that are topologically close for performance or cost reasons. However, I want
251+
to avoid connection failures if no sufficiently close endpoints are available.
252+
* **Solution:** Set `routingPreference: Close`
264253
* **Effect:** The Kubernetes implementation will aim to prioritize routing
265254
traffic to endpoints in the same zone as the client. If no endpoints are
266255
available within the zone, traffic will be routed to other zones. It's
@@ -269,16 +258,6 @@ NOTE: Implementations reserve the right to refine the behavior associated with
269258
resources within the zone if this becomes a concern.
270259

271260
#### Story 3
272-
* **Requirement:** I prioritize application availability and want to minimize the
273-
risk of outages due to localized overload. I'm willing to accept potentially
274-
higher costs associated with cross-zone traffic distribution.
275-
* **Solution:** Set `routingPreference: Spread`
276-
* **Effect:** The Kubernetes implementation will try to distribute traffic as
277-
equally as possible across endpoints, potentially spanning multiple zones or
278-
regions. This can improve resilience but might lead to increased network
279-
traffic costs.
280-
281-
#### Story 4
282261
* **Requirement:** As a developer of a widely deployed cluster-addon, I want to
283262
be able to provide users an easy way to configure my Helm chart and/or
284263
deployment configuration to enable same-zone routing behavior in a portable
@@ -289,7 +268,7 @@ NOTE: Implementations reserve the right to refine the behavior associated with
289268
implementation. This simplifies their deployment process and reduces the
290269
complexity of managing cross-cluster applications.
291270

292-
#### Story 5
271+
#### Story 4
293272
* **Requirement:** I have some other precise preferences for how traffic should
294273
be routed, and I know that my chosen implementation supports the desired
295274
preference.
@@ -306,16 +285,17 @@ configuration. There's a non-zero chance that we may need to revisit this again.
306285

307286
### Risks and Mitigations
308287

309-
* **Risk:** Having a routing preference like `Zone` comes at the risk of
310-
endpoints in certain zones being overloaded if the originating traffic is
311-
skewed towards a particular zone.
288+
* **Risk:** Having a routing preference like `Close` comes at the risk of
289+
endpoints in certain locality being overloaded if the originating traffic is
290+
skewed towards a particular locality.
312291

313292
**Mitigation:**
314-
* Emphasize in the documentation that the `Zone` preference is
315-
designed for low-latency or monetory-cost reasons, with the understanding
316-
that it can lead to overload within zones.
317-
* Recommend approaches like having deployments per zone which can scale
318-
independently of other zones.
293+
* Emphasize in the documentation that the `Close` preference is designed for
294+
low-latency or monetory-cost reasons, with the understanding that it can
295+
lead to overload within that locality.
296+
* Recommend approaches like having deployments per locality, (like a zone
297+
locality when using kube-proxy as the data-plane), which can scale
298+
independently of other localities.
319299

320300
* **Risk:** Users migrating from the `service.kubernetes.io/topology-mode`
321301
annotation might encounter differences in exact routing behavior:
@@ -333,26 +313,30 @@ configuration. There's a non-zero chance that we may need to revisit this again.
333313
### Standard Heuristic Implementation (kube-proxy dataplane)
334314

335315
kube-proxy (along with EndpointSlice controller, within kube-controller-manager
336-
as the control plane) will support the three standard routing preferences
337-
(`Default`, `Spread`, `Zone`).
316+
as the control plane) will support the two standard routing preferences
317+
(`Default`, `Close`).
338318

339-
#### `Default` and `Spread`
340-
* Initially, kube-proxy will treat the `Default` preference the same as
341-
`Spread`
319+
#### `Default`
320+
* **Meaning:** `Default` value for kube-proxy would match it's existing
321+
behaviour of having an equal distribution of traffic across endpoints
322+
(potentially spanning multiple zones or regions)
342323
* This leverages existing implementation, requiring no major changes.
343324

344-
#### `Zone`
325+
#### `Close`
326+
* **Meaning:** Attempts to route traffic to endpoints within the same zone as
327+
the client. If no endpoints are available within the zone, traffic would be
328+
routed to other zones.
345329
* This preference will be implemented by the use of Hints within EndpointSlices.
346330
* We already use Hints to implement `service.kubernetes.io/topology-mode: Auto`
347331
In a similar manner, the EndpointSlice controller will now also populate hints
348-
for `routingPreference: Zone` -- although in this case, the zone hint will
332+
for `routingPreference: Close` -- although in this case, the zone hint will
349333
match the endpoint of the zone itself.
350334
* While it may seem redundant to populate the hints here since kube-proxy can
351335
already derive the zone hint from the endpoints zone (as they would be the
352336
same), we will still use this for implementation simply because of the reason
353337
that it’s easier to implement and provides a better design. Consider an
354338
alternative implementation where kube-proxy reads
355-
`routingPreference: Zone` field and then constructs the route rules
339+
`routingPreference: Close` field and then constructs the route rules
356340
accordingly. This means some extra logic needs to be baked into the kube-proxy
357341
which could have just as easily been implemented by an already existing
358342
extensibility mechanism (i.e. EndpointSlice hints)
@@ -531,14 +515,14 @@ The following packages will also see minor changes:
531515
##### Integration tests
532516

533517
* Verify that if both the annotation `service.kubernetes.io/topology-mode: Auto`
534-
and field `routingPreference: Zone` are configured, precedence is given to the
535-
annotation.
518+
and field `routingPreference: Close` are configured, precedence is given to
519+
the annotation.
536520

537521
##### e2e tests
538522

539523
* Verify that EndpointSlice hints are correctly populated when
540-
`routingPreference` is set to `Zone`.
541-
* Verify through probes that for `routingPreference: Zone`, requests originating
524+
`routingPreference` is set to `Close`.
525+
* Verify through probes that for `routingPreference: Close`, requests originating
542526
from a zone which has service pods get sent to a pod in the same zone. For
543527
requests originating from zones with no service pods, requests should not get
544528
blackholed and should rather be forwarded to any service pod from the cluster.
@@ -877,8 +861,8 @@ along the following lines:
877861
### Reuse the fields internal/externalTrafficPolicy to offer these routing preferences
878862

879863
This has been a major topic of discussion in the past, with questions around
880-
which field would be appropriate to support a heuristic like `Zone`. If we were
881-
to in fact use this approach we would be faced with the dilemma of choosing
864+
which field would be appropriate to support a heuristic like `PreferZone`. If we
865+
were to in fact use this approach we would be faced with the dilemma of choosing
882866
between two less-than-ideal options:
883867

884868
* Dilute purpose and sacrifice semantic expectation
@@ -893,14 +877,14 @@ between two less-than-ideal options:
893877
node since the logs would then report an incorrect log source.”. Values like
894878
"Local" mandate that traffic must remain within the Node boundary.
895879

896-
* **Problem:** Introducing routing preferences like `Zone` would dilute this
897-
clear semantic meaning and could create potential misinterpretations. Using
898-
a separate field dedicated to routing preferences avoids this confusion and
899-
maintains consistency.
880+
* **Problem:** Introducing routing preferences like `PreferZone` would dilute
881+
this clear semantic meaning and could create potential misinterpretations.
882+
Using a separate field dedicated to routing preferences avoids this
883+
confusion and maintains consistency.
900884

901885
* Become inflexible or rigid
902886

903-
* Alternatively, if we introduce `Zone` without diluting the meaning of
887+
* Alternatively, if we introduce `PreferZone` without diluting the meaning of
904888
the existing fields, we'd need to create extremely specific and inflexible
905889
rules for how it works across all implementations.
906890

@@ -930,8 +914,8 @@ like `routingPreference` might be a better option is:
930914
the Gateway API.
931915

932916
* The `routingPreference` field elegantly balances control and abstraction.
933-
Users can influence behavior with high-level heuristics (`Zone`, `Spread`)
934-
while implementations handle the underlying complexity. Heuristics can flag
917+
Users can influence behavior with high-level heuristics (like `Close`) while
918+
implementations handle the underlying complexity. Heuristics can flag
935919
potential issues and guide users towards safe configurations. Using
936920
independent fields increases the risk of unintended consequences, as
937921
interactions between seemingly unrelated settings can create unexpected and
@@ -988,7 +972,7 @@ Rather than having to choose between the two, Pod Topology Spread Constraints
988972
and `routingPreference` can offer slightly better and resilient traffic
989973
distribution when used in conjunction.
990974

991-
* Users can set `routingPreference` to `Zone` to express the preference for
975+
* Users can set `routingPreference` to `Close` to express the preference for
992976
keeping traffic within the same zone as the client.
993977
* Then, they can configure Pod Topology Spread Constraints to Ensure balanced
994978
pod distribution across zones, maximizing the likelihood that the

0 commit comments

Comments
 (0)