forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LoadBalancer in BackendTrafficPolicy (envoyproxy#2063)
* LoadBalancer in BackendTrafficPolicy Fixes: envoyproxy#1105 Signed-off-by: Arko Dasgupta <arko@tetrate.io> * tests Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: zirain <zirain2009@gmail.com>
- Loading branch information
Showing
9 changed files
with
615 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package v1alpha1 | ||
|
||
// LoadBalancer defines the load balancer policy to be applied. | ||
// +union | ||
type LoadBalancer struct { | ||
// Type decides the type of Load Balancer policy. | ||
// Valid RateLimitType values are | ||
// "ConsistentHash", | ||
// "LeastRequest", | ||
// "Random", | ||
// "RoundRobin", | ||
// | ||
// +unionDiscriminator | ||
Type LoadBalancerType `json:"type"` | ||
// ConsistentHash defines the configuration when the load balancer type is | ||
// set to ConsistentHash | ||
// | ||
// +optional | ||
ConsistentHash *ConsistentHash `json:"consistentHash,omitempty"` | ||
} | ||
|
||
// LoadBalancerType specifies the types of LoadBalancer. | ||
// +kubebuilder:validation:Enum=ConsistentHash;LeastRequest;Random;RoundRobin | ||
type LoadBalancerType string | ||
|
||
const ( | ||
// ConsistentHashLoadBalancerType load balancer policy. | ||
ConsistentHashLoadBalancerType LoadBalancerType = "ConsistentHash" | ||
// LeastRequestLoadBalancerType load balancer policy. | ||
LeastRequestLoadBalancerType LoadBalancerType = "LeastRequest" | ||
// RandomLoadBalancerType load balancer policy. | ||
RandomLoadBalancerType LoadBalancerType = "Random" | ||
// RoundRobinLoadBalancerType load balancer policy. | ||
RoundRobinLoadBalancerType LoadBalancerType = "RoundRobin" | ||
) | ||
|
||
// ConsistentHash defines the configuration related to the consistent hash | ||
// load balancer policy | ||
type ConsistentHash struct { | ||
Type ConsistentHashType `json:"type"` | ||
} | ||
|
||
// ConsistentHashType defines the type of input to hash on. | ||
// +kubebuilder:validation:Enum=SourceIP | ||
type ConsistentHashType string | ||
|
||
const ( | ||
// SourceIPConsistentHashType hashes based on the source IP address. | ||
SourceIPConsistentHashType ConsistentHashType = "SourceIP" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
internal/gatewayapi/testdata/backendtrafficpolicy-with-loadbalancer.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-2 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
grpcRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1alpha2 | ||
kind: GRPCRoute | ||
metadata: | ||
namespace: default | ||
name: grpcroute-1 | ||
spec: | ||
parentRefs: | ||
- namespace: envoy-gateway | ||
name: gateway-1 | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
namespace: default | ||
name: httproute-1 | ||
spec: | ||
hostnames: | ||
- gateway.envoyproxy.io | ||
parentRefs: | ||
- namespace: envoy-gateway | ||
name: gateway-2 | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- path: | ||
value: "/" | ||
backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
backendTrafficPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: BackendTrafficPolicy | ||
metadata: | ||
namespace: envoy-gateway | ||
name: policy-for-gateway | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
loadBalancer: | ||
type: Random | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: BackendTrafficPolicy | ||
metadata: | ||
namespace: default | ||
name: policy-for-route | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
name: httproute-1 | ||
namespace: default | ||
loadBalancer: | ||
type: ConsistentHash | ||
consistentHash: | ||
type: SourceIP |
Oops, something went wrong.