Skip to content

Commit 35e3b60

Browse files
Inode1i.makarychev
andauthored
feat add query parameter to lb hash policy (#7428)
rename queryParam to queryParams Signed-off-by: i.makarychev <[email protected]> Co-authored-by: i.makarychev <[email protected]>
1 parent 7fb3254 commit 35e3b60

26 files changed

+1407
-8
lines changed

api/v1alpha1/loadbalancer_types.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ const (
7272
// +kubebuilder:validation:XValidation:rule="self.type == 'Header' ? has(self.header) : !has(self.header)",message="If consistent hash type is header, the header field must be set."
7373
// +kubebuilder:validation:XValidation:rule="self.type == 'Headers' ? has(self.headers) : !has(self.headers)",message="If consistent hash type is headers, the headers field must be set."
7474
// +kubebuilder:validation:XValidation:rule="self.type == 'Cookie' ? has(self.cookie) : !has(self.cookie)",message="If consistent hash type is cookie, the cookie field must be set."
75+
// +kubebuilder:validation:XValidation:rule="self.type == 'QueryParams' ? has(self.queryParams) : !has(self.queryParams)",message="If consistent hash type is queryParams, the queryParams field must be set."
7576
type ConsistentHash struct {
7677
// ConsistentHashType defines the type of input to hash on. Valid Type values are
7778
// "SourceIP",
7879
// "Header",
7980
// "Headers",
8081
// "Cookie".
82+
// "QueryParams".
8183
//
8284
// +unionDiscriminator
8385
Type ConsistentHashType `json:"type"`
@@ -98,6 +100,11 @@ type ConsistentHash struct {
98100
// +optional
99101
Cookie *Cookie `json:"cookie,omitempty"`
100102

103+
// QueryParams configures the query parameter hash policy when the consistent hash type is set to QueryParams.
104+
//
105+
// +optional
106+
QueryParams []*QueryParam `json:"queryParams,omitempty"`
107+
101108
// The table size for consistent hashing, must be prime number limited to 5000011.
102109
//
103110
// +kubebuilder:validation:Minimum=2
@@ -114,6 +121,13 @@ type Header struct {
114121
Name string `json:"name"`
115122
}
116123

124+
// QueryParam defines the query parameter name hashing configuration for consistent hash based
125+
// load balancing.
126+
type QueryParam struct {
127+
// Name of the query param to hash.
128+
Name string `json:"name"`
129+
}
130+
117131
// Cookie defines the cookie hashing configuration for consistent hash based
118132
// load balancing.
119133
type Cookie struct {
@@ -135,7 +149,7 @@ type Cookie struct {
135149
}
136150

137151
// ConsistentHashType defines the type of input to hash on.
138-
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie
152+
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie;QueryParams
139153
type ConsistentHashType string
140154

141155
const (
@@ -149,6 +163,8 @@ const (
149163
HeadersConsistentHashType ConsistentHashType = "Headers"
150164
// CookieConsistentHashType hashes based on a cookie.
151165
CookieConsistentHashType ConsistentHashType = "Cookie"
166+
// QueryParamsConsistentHashType hashes based on a multiple query parameter.
167+
QueryParamsConsistentHashType ConsistentHashType = "QueryParams"
152168
)
153169

154170
// SlowStart defines the configuration related to the slow start load balancer policy.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 26 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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,21 @@ spec:
737737
- name
738738
type: object
739739
type: array
740+
queryParams:
741+
description: QueryParams configures the query parameter hash
742+
policy when the consistent hash type is set to QueryParams.
743+
items:
744+
description: |-
745+
QueryParam defines the query parameter name hashing configuration for consistent hash based
746+
load balancing.
747+
properties:
748+
name:
749+
description: Name of the query param to hash.
750+
type: string
751+
required:
752+
- name
753+
type: object
754+
type: array
740755
tableSize:
741756
default: 65537
742757
description: The table size for consistent hashing, must be
@@ -752,11 +767,13 @@ spec:
752767
"Header",
753768
"Headers",
754769
"Cookie".
770+
"QueryParams".
755771
enum:
756772
- SourceIP
757773
- Header
758774
- Headers
759775
- Cookie
776+
- QueryParams
760777
type: string
761778
required:
762779
- type
@@ -771,6 +788,10 @@ spec:
771788
- message: If consistent hash type is cookie, the cookie field
772789
must be set.
773790
rule: 'self.type == ''Cookie'' ? has(self.cookie) : !has(self.cookie)'
791+
- message: If consistent hash type is queryParams, the queryParams
792+
field must be set.
793+
rule: 'self.type == ''QueryParams'' ? has(self.queryParams)
794+
: !has(self.queryParams)'
774795
endpointOverride:
775796
description: |-
776797
EndpointOverride defines the configuration for endpoint override.

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,22 @@ spec:
796796
- name
797797
type: object
798798
type: array
799+
queryParams:
800+
description: QueryParams configures the query parameter
801+
hash policy when the consistent hash type is set
802+
to QueryParams.
803+
items:
804+
description: |-
805+
QueryParam defines the query parameter name hashing configuration for consistent hash based
806+
load balancing.
807+
properties:
808+
name:
809+
description: Name of the query param to hash.
810+
type: string
811+
required:
812+
- name
813+
type: object
814+
type: array
799815
tableSize:
800816
default: 65537
801817
description: The table size for consistent hashing,
@@ -811,11 +827,13 @@ spec:
811827
"Header",
812828
"Headers",
813829
"Cookie".
830+
"QueryParams".
814831
enum:
815832
- SourceIP
816833
- Header
817834
- Headers
818835
- Cookie
836+
- QueryParams
819837
type: string
820838
required:
821839
- type
@@ -833,6 +851,10 @@ spec:
833851
field must be set.
834852
rule: 'self.type == ''Cookie'' ? has(self.cookie)
835853
: !has(self.cookie)'
854+
- message: If consistent hash type is queryParams, the
855+
queryParams field must be set.
856+
rule: 'self.type == ''QueryParams'' ? has(self.queryParams)
857+
: !has(self.queryParams)'
836858
endpointOverride:
837859
description: |-
838860
EndpointOverride defines the configuration for endpoint override.

0 commit comments

Comments
 (0)