Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for LoadBalancing Strategy in EnvoyProxy API #1477

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean, eds will just send ClusterIP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is what is happening as of v0.4.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if I'm wrong, only ClusterIP will change the result of EDS, other types only change LbPolicy on envoy cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah thats right :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this's a little odd to me, Is there any way to make them more consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you share why its odd, this API is meant for end users (platform owners / app owners) to configure LB policy, so they can

  • Use LB Policies provided at a L7 request level by Envoy (round-robin, least request, etc) or
  • LB Policies provided at a L3/L4 flow level by another intermediate data plane entity such as kube-proxy

)

// 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