Skip to content

Commit 8673702

Browse files
authored
feat: support endpoint override policy based routing (#6458)
* feat: support endpoint override policy based routing Signed-off-by: bitliu <[email protected]> * remove metadata Signed-off-by: bitliu <[email protected]> * update docs Signed-off-by: bitliu <[email protected]> * revert cel rule Signed-off-by: bitliu <[email protected]> * resolve feedbacks Signed-off-by: bitliu <[email protected]> * update Signed-off-by: bitliu <[email protected]> * fix e2e Signed-off-by: bitliu <[email protected]> * fix lint Signed-off-by: bitliu <[email protected]> --------- Signed-off-by: bitliu <[email protected]>
1 parent 98191e6 commit 8673702

File tree

31 files changed

+3188
-0
lines changed

31 files changed

+3188
-0
lines changed

api/v1alpha1/loadbalancer_types.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ type LoadBalancer struct {
2929
// +optional
3030
ConsistentHash *ConsistentHash `json:"consistentHash,omitempty"`
3131

32+
// EndpointOverride defines the configuration for endpoint override.
33+
// When specified, the load balancer will attempt to route requests to endpoints
34+
// based on the override information extracted from request headers or metadata.
35+
// If the override endpoints are not available, the configured load balancer policy will be used as fallback.
36+
//
37+
// +optional
38+
EndpointOverride *EndpointOverride `json:"endpointOverride,omitempty"`
39+
3240
// SlowStart defines the configuration related to the slow start load balancer policy.
3341
// If set, during slow start window, traffic sent to the newly added hosts will gradually increase.
3442
// Currently this is only supported for RoundRobin and LeastRequest load balancers
@@ -178,3 +186,26 @@ type ForceLocalZone struct {
178186
// +notImplementedHide
179187
MinEndpointsInZoneThreshold *uint32 `json:"minEndpointsInZoneThreshold,omitempty"`
180188
}
189+
190+
// EndpointOverride defines the configuration for endpoint override.
191+
// This allows endpoint picking to be implemented based on request headers or metadata.
192+
// It extracts selected override endpoints from the specified sources (request headers, metadata, etc.).
193+
// If no valid endpoint in the override list, then the configured load balancing policy is used as fallback.
194+
type EndpointOverride struct {
195+
// ExtractFrom defines the sources to extract endpoint override information from.
196+
//
197+
// +kubebuilder:validation:MinItems=1
198+
// +kubebuilder:validation:MaxItems=10
199+
ExtractFrom []EndpointOverrideExtractFrom `json:"extractFrom"`
200+
}
201+
202+
// EndpointOverrideExtractFrom defines a source to extract endpoint override information from.
203+
type EndpointOverrideExtractFrom struct {
204+
// Header defines the header to get the override endpoint addresses.
205+
// The header value must specify at least one endpoint in `IP:Port` format or multiple endpoints in `IP:Port,IP:Port,...` format.
206+
// For example `10.0.0.5:8080` or `[2600:4040:5204::1574:24ae]:80`.
207+
// The IPv6 address is enclosed in square brackets.
208+
//
209+
// +optional
210+
Header *string `json:"header,omitempty"`
211+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,34 @@ spec:
668668
- message: If consistent hash type is cookie, the cookie field
669669
must be set.
670670
rule: 'self.type == ''Cookie'' ? has(self.cookie) : !has(self.cookie)'
671+
endpointOverride:
672+
description: |-
673+
EndpointOverride defines the configuration for endpoint override.
674+
When specified, the load balancer will attempt to route requests to endpoints
675+
based on the override information extracted from request headers or metadata.
676+
If the override endpoints are not available, the configured load balancer policy will be used as fallback.
677+
properties:
678+
extractFrom:
679+
description: ExtractFrom defines the sources to extract endpoint
680+
override information from.
681+
items:
682+
description: EndpointOverrideExtractFrom defines a source
683+
to extract endpoint override information from.
684+
properties:
685+
header:
686+
description: |-
687+
Header defines the header to get the override endpoint addresses.
688+
The header value must specify at least one endpoint in `IP:Port` format or multiple endpoints in `IP:Port,IP:Port,...` format.
689+
For example `10.0.0.5:8080` or `[2600:4040:5204::1574:24ae]:80`.
690+
The IPv6 address is enclosed in square brackets.
691+
type: string
692+
type: object
693+
maxItems: 10
694+
minItems: 1
695+
type: array
696+
required:
697+
- extractFrom
698+
type: object
671699
slowStart:
672700
description: |-
673701
SlowStart defines the configuration related to the slow start load balancer policy.

charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_envoyextensionpolicies.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,35 @@ spec:
746746
field must be set.
747747
rule: 'self.type == ''Cookie'' ? has(self.cookie)
748748
: !has(self.cookie)'
749+
endpointOverride:
750+
description: |-
751+
EndpointOverride defines the configuration for endpoint override.
752+
When specified, the load balancer will attempt to route requests to endpoints
753+
based on the override information extracted from request headers or metadata.
754+
If the override endpoints are not available, the configured load balancer policy will be used as fallback.
755+
properties:
756+
extractFrom:
757+
description: ExtractFrom defines the sources to
758+
extract endpoint override information from.
759+
items:
760+
description: EndpointOverrideExtractFrom defines
761+
a source to extract endpoint override information
762+
from.
763+
properties:
764+
header:
765+
description: |-
766+
Header defines the header to get the override endpoint addresses.
767+
The header value must specify at least one endpoint in `IP:Port` format or multiple endpoints in `IP:Port,IP:Port,...` format.
768+
For example `10.0.0.5:8080` or `[2600:4040:5204::1574:24ae]:80`.
769+
The IPv6 address is enclosed in square brackets.
770+
type: string
771+
type: object
772+
maxItems: 10
773+
minItems: 1
774+
type: array
775+
required:
776+
- extractFrom
777+
type: object
749778
slowStart:
750779
description: |-
751780
SlowStart defines the configuration related to the slow start load balancer policy.

0 commit comments

Comments
 (0)