Skip to content

Commit

Permalink
API for LoadBalancing Strategy in EnvoyProxy API
Browse files Browse the repository at this point in the history
* Allows the user to configure a global load balancing strategy
for the envoy proxy data plane

```
apiVersion: config.gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  name: set-lb-strategy
spec:
  traffic:
    loadBalancer:
      strategy: LeastRequest
```
* Sets the default load balancing strategy to `LeastRequest` which
will internally set the `WeightedLeastReqquest` knob in Envoy

* Relates to envoyproxy#1256 allowing
the user to fall back to `ClusterIP` style loadbalancing

* Relates to envoyproxy#1105

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
  • Loading branch information
arkodg committed Jun 3, 2023
1 parent 572c495 commit 2371a28
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
46 changes: 46 additions & 0 deletions api/config/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type EnvoyProxySpec struct {
//
// +optional
Bootstrap *string `json:"bootstrap,omitempty"`
// Traffic settings in the data plane.
// +optional
Traffic *EnvoyProxyTrafficSettings `json:"traffic,omitempty"`
}

// EnvoyProxyProvider defines the desired state of a resource provider.
Expand Down Expand Up @@ -164,6 +167,49 @@ const (
LogLevelError LogLevel = "error"
)

// EnvoyProxyTrafficSettings defines the traffic settings for requests being
// processed by the EnvoyProxy data plane.
type EnvoyProxyTrafficSettings struct {
// LoadBalancer defines the load balancer settings between
// the Envoy Proxy data plane and the upstream hosts.
//
// +optional
LoadBalancer *EnvoyProxyLoadBalancerSetting `json:"loadBalancer,omitempty"`
}

type EnvoyProxyLoadBalancerSetting struct {
// Strategy for load balancing.
//
// +kubebuilder:default=LeastRequest
Strategy LoadBalancerStrategy `json:"strategy,omitempty"`
}

// LoadBalancerStrategy defines the type of load balancing strategy to use.
//
// +kubebuilder:validation:Enum=LeastRequest;RoundRobin;Random;ClusterIP
type LoadBalancerStrategy string

const (
// LoadBalancerStrategyLeastRequest defines the "LeastRequest" load balancing strategy.
// In this mode, the upstream hosts is picked based on fewer active requests.
// Visit https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#weighted-least-request for more details.
LoadBalancerStrategyLeastRequest LoadBalancerStrategy = "LeastRequest"

// LoadBalancerStrategyRoundRobin defines the "RoundRobin" load balancing strategy.
// In this mode, the upstream host is selected in weighed round robin order.
// Visit https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers#weighted-round-robin for more details.
LoadBalancerStrategyRoundRobin LoadBalancerStrategy = "RoundRobin"

// LoadBalancerStrategyRandom defines the "Random" load balancing strategy.
// In this mode, the upstream host is chosen randomly.
LoadBalancerStrategyRandom LoadBalancerStrategy = "Random"

// LoadBalancerStrategyClusterIP defines the "ClusterIP" load balancing strategy.
// In this mode, EnvoyProxy routes requests to the ClusterIP of the service and
// relies on another entity such as kube-proxy to perform load balancing to the upstream hosts.
LoadBalancerStrategyClusterIP LoadBalancerStrategy = "ClusterIP"
)

// EnvoyProxyStatus defines the observed state of EnvoyProxy. This type is not implemented
// until https://github.com/envoyproxy/gateway/issues/1007 is fixed.
type EnvoyProxyStatus struct {
Expand Down
40 changes: 40 additions & 0 deletions api/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3836,6 +3836,24 @@ spec:
required:
- type
type: object
traffic:
description: Traffic settings in the data plane.
properties:
loadBalancer:
description: LoadBalancer defines the load balancer settings between
the Envoy Proxy data plane and the upstream hosts.
properties:
strategy:
default: LeastRequest
description: Strategy for load balancing.
enum:
- LeastRequest
- RoundRobin
- Random
- ClusterIP
type: string
type: object
type: object
type: object
status:
description: EnvoyProxyStatus defines the actual state of EnvoyProxy.
Expand Down
40 changes: 40 additions & 0 deletions docs/latest/api/config_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ _Appears in:_
| `envoyService` _[KubernetesServiceSpec](#kubernetesservicespec)_ | EnvoyService defines the desired state of the Envoy service resource. If unspecified, default settings for the manged Envoy service resource are applied. |


## EnvoyProxyLoadBalancerSetting





_Appears in:_
- [EnvoyProxyTrafficSettings](#envoyproxytrafficsettings)

| Field | Description |
| --- | --- |
| `strategy` _[LoadBalancerStrategy](#loadbalancerstrategy)_ | Strategy for load balancing. |


## EnvoyProxyProvider


Expand Down Expand Up @@ -215,9 +229,24 @@ _Appears in:_
| `logging` _[ProxyLogging](#proxylogging)_ | Logging defines logging parameters for managed proxies. If unspecified, default settings apply. This type is not implemented until https://github.com/envoyproxy/gateway/issues/280 is fixed. |
| `accessLoggings` _[ProxyAccessLogging](#proxyaccesslogging) array_ | AccessLoggings defines access logging parameters for managed proxies. If unspecified, access log is disabled. |
| `bootstrap` _string_ | Bootstrap defines the Envoy Bootstrap as a YAML string. Visit https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-msg-config-bootstrap-v3-bootstrap to learn more about the syntax. If set, this is the Bootstrap configuration used for the managed Envoy Proxy fleet instead of the default Bootstrap configuration set by Envoy Gateway. Some fields within the Bootstrap that are required to communicate with the xDS Server (Envoy Gateway) and receive xDS resources from it are not configurable and will result in the `EnvoyProxy` resource being rejected. Backward compatibility across minor versions is not guaranteed. We strongly recommend using `egctl x translate` to generate a `EnvoyProxy` resource with the `Bootstrap` field set to the default Bootstrap configuration used. You can edit this configuration, and rerun `egctl x translate` to ensure there are no validation errors. |
| `traffic` _[EnvoyProxyTrafficSettings](#envoyproxytrafficsettings)_ | Traffic settings in the data plane. |




## EnvoyProxyTrafficSettings



EnvoyProxyTrafficSettings defines the traffic settings for requests being processed by the EnvoyProxy data plane.

_Appears in:_
- [EnvoyProxySpec](#envoyproxyspec)

| Field | Description |
| --- | --- |
| `loadBalancer` _[EnvoyProxyLoadBalancerSetting](#envoyproxyloadbalancersetting)_ | LoadBalancer defines the load balancer settings between the Envoy Proxy data plane and the upstream hosts. |


## Extension

Expand Down Expand Up @@ -430,6 +459,17 @@ _Appears in:_
| `Namespaces` _string array_ | Namespaces holds the list of namespaces that Envoy Gateway will watch for namespaced scoped resources such as Gateway, HTTPRoute and Service. Note that Envoy Gateway will continue to reconcile relevant cluster scoped resources such as GatewayClass that it is linked to. By default, when this field is unset or empty, Envoy Gateway will watch for input namespaced resources from all namespaces. |


## LoadBalancerStrategy

_Underlying type:_ `string`

LoadBalancerStrategy defines the type of load balancing strategy to use.

_Appears in:_
- [EnvoyProxyLoadBalancerSetting](#envoyproxyloadbalancersetting)



## LogComponent

_Underlying type:_ `string`
Expand Down

0 comments on commit 2371a28

Please sign in to comment.