projectcontour / contour

Contour is a Kubernetes ingress controller using Envoy proxy.
https://projectcontour.io
Apache License 2.0
3.71k stars 673 forks source link

Zone aware routing #2859

Open dsvetl opened 4 years ago

dsvetl commented 4 years ago

Hi, projectcontour,

You need to add the ability to contour to use this functionality in envoy

https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/zone_aware#arch-overview-load-balancing-zone-aware-routing

I wish we can parse pod region/zone to provide this info into xDS API.

stevesloka commented 4 years ago

I think this would be super interesting @dsvetl! The tricky part is finding out what you describe as a "zone". I know there are labels that get applied to nodes. So a quick thought would be to parse which endpoint is running on which node, then filter that information back into Envoy so it can make decisions on where to route to next.

We'd need to probably come up with a design doc to outline how this might work, how it might integrate into Contour, as well as how users would configure.

jpeach commented 4 years ago

xref https://github.com/kubernetes/enhancements/issues/536

jpeach commented 4 years ago

@dsvetl This is a pretty open ended project, and we are not likely to tackle is in the immediate future. If you have a proposal for how zones should be defined and handled in Contour+Envoy, we can help you design and implement that.

nefelim4ag commented 3 years ago

I think we can take a simple K8s approach first:

youngnick commented 3 years ago

Sorry to take a long time to respond here, I've been hoping to spend some time to take a look at some of the newer changes upstream (like NetworkTopology and similar things), before responding, but I have not had bandwidth yet.

I think the rough approach outlined by @Nefelim4ag sound reasonable at first glance, but this one will definitely need a design document that runs through:

nefelim4ag commented 1 year ago

Some time has already passed, and we now have some ready instruments to deal with it:

I already spend some time writing in-house side-car zone routing with Envoy (based on Priority). Cases with separate contour controllers from envoy nodes are not so obvious to implement as with sidecar.

I see the following design (I can make a PR on request):

Design proposal

Status: Draft

zone-aware-routing-design.md.

Abstract

Zone-aware routing is a GA feature of Kubernetes which is good to support.

Background

This feature was requested in #2859. Contour is heavily used in cloud deployments, where nodes & pods can be distributed across zones. Traffic across zones incurs latency and data charges. Consequently, load distribution with zone-aware traffic routing shall decrease latency and TCO.

Goals

Non Goals

High-Level Design

Detailed Design

* Return EDS LocalityLbEndpoints based on xDS client IP? In the case of [LocalityWeightedLbConfig](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/locality_weight#arch-overview-load-balancing-locality-weighted-lb): * Add new LB method to CRD * Enrich LocalityLbEndpoints with weight In case of [Priority](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/priority#arch-overview-load-balancing-priority-levels): * Enrich LocalityLbEndpoints with priority. 0 for local zone, 1 for others. ## Alternatives Considered Make envoy [zone aware](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/zone_aware). No information on how to properly implement it. Looks like an East-West solution instead of North-South. ## Security Considerations N/A ## Compatibility Kubernetes 1.21+ ## Implementation