Skip to content

Commit 208dbed

Browse files
author
i.makarychev
committed
feat add query parameter to lb hash policy
Signed-off-by: i.makarychev <[email protected]> Signed-off-by: i.makarychev <[email protected]>
1 parent 9935819 commit 208dbed

26 files changed

+856
-8
lines changed

api/v1alpha1/loadbalancer_types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,25 @@ const (
6565
RoundRobinLoadBalancerType LoadBalancerType = "RoundRobin"
6666
)
6767

68+
// QueryParameterName defines the query parameter name hashing configuration for consistent hash based
69+
// load balancing.
70+
type QueryParameter string
71+
6872
// ConsistentHash defines the configuration related to the consistent hash
6973
// load balancer policy.
7074
// +union
7175
//
7276
// +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."
7377
// +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."
7478
// +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."
79+
// +kubebuilder:validation:XValidation:rule="self.type == 'QueryParameter' ? has(self.queryParameter) : !has(self.queryParameter)",message="If consistent hash type is queryParameter, the queryParameter field must be set."
7580
type ConsistentHash struct {
7681
// ConsistentHashType defines the type of input to hash on. Valid Type values are
7782
// "SourceIP",
7883
// "Header",
7984
// "Headers",
8085
// "Cookie".
86+
// "QueryParameter".
8187
//
8288
// +unionDiscriminator
8389
Type ConsistentHashType `json:"type"`
@@ -98,6 +104,11 @@ type ConsistentHash struct {
98104
// +optional
99105
Cookie *Cookie `json:"cookie,omitempty"`
100106

107+
// QueryParameter configures the qery parameter hash policy when the consistent hash type is set to QueryParameter.
108+
//
109+
// +optional
110+
QueryParameter *QueryParameter `json:"queryParameter,omitempty"`
111+
101112
// The table size for consistent hashing, must be prime number limited to 5000011.
102113
//
103114
// +kubebuilder:validation:Minimum=2
@@ -135,7 +146,7 @@ type Cookie struct {
135146
}
136147

137148
// ConsistentHashType defines the type of input to hash on.
138-
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie
149+
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie;QueryParameter
139150
type ConsistentHashType string
140151

141152
const (
@@ -149,6 +160,8 @@ const (
149160
HeadersConsistentHashType ConsistentHashType = "Headers"
150161
// CookieConsistentHashType hashes based on a cookie.
151162
CookieConsistentHashType ConsistentHashType = "Cookie"
163+
// QueryParameterConsistentHashType hashes based on a query parameter.
164+
QueryParameterConsistentHashType ConsistentHashType = "QueryParameter"
152165
)
153166

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

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ spec:
736736
- name
737737
type: object
738738
type: array
739+
queryParameter:
740+
description: QueryParameter configures the qery parameter
741+
hash policy when the consistent hash type is set to QueryParameter.
742+
type: string
739743
tableSize:
740744
default: 65537
741745
description: The table size for consistent hashing, must be
@@ -751,11 +755,13 @@ spec:
751755
"Header",
752756
"Headers",
753757
"Cookie".
758+
"QueryParameter".
754759
enum:
755760
- SourceIP
756761
- Header
757762
- Headers
758763
- Cookie
764+
- QueryParameter
759765
type: string
760766
required:
761767
- type
@@ -770,6 +776,10 @@ spec:
770776
- message: If consistent hash type is cookie, the cookie field
771777
must be set.
772778
rule: 'self.type == ''Cookie'' ? has(self.cookie) : !has(self.cookie)'
779+
- message: If consistent hash type is queryParameter, the queryParameter
780+
field must be set.
781+
rule: 'self.type == ''QueryParameter'' ? has(self.queryParameter)
782+
: !has(self.queryParameter)'
773783
endpointOverride:
774784
description: |-
775785
EndpointOverride defines the configuration for endpoint override.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@ spec:
776776
- name
777777
type: object
778778
type: array
779+
queryParameter:
780+
description: QueryParameter configures the qery
781+
parameter hash policy when the consistent hash
782+
type is set to QueryParameter.
783+
type: string
779784
tableSize:
780785
default: 65537
781786
description: The table size for consistent hashing,
@@ -791,11 +796,13 @@ spec:
791796
"Header",
792797
"Headers",
793798
"Cookie".
799+
"QueryParameter".
794800
enum:
795801
- SourceIP
796802
- Header
797803
- Headers
798804
- Cookie
805+
- QueryParameter
799806
type: string
800807
required:
801808
- type
@@ -813,6 +820,10 @@ spec:
813820
field must be set.
814821
rule: 'self.type == ''Cookie'' ? has(self.cookie)
815822
: !has(self.cookie)'
823+
- message: If consistent hash type is queryParameter,
824+
the queryParameter field must be set.
825+
rule: 'self.type == ''QueryParameter'' ? has(self.queryParameter)
826+
: !has(self.queryParameter)'
816827
endpointOverride:
817828
description: |-
818829
EndpointOverride defines the configuration for endpoint override.

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11751,6 +11751,12 @@ spec:
1175111751
- name
1175211752
type: object
1175311753
type: array
11754+
queryParameter:
11755+
description: QueryParameter configures
11756+
the qery parameter hash policy
11757+
when the consistent hash type
11758+
is set to QueryParameter.
11759+
type: string
1175411760
tableSize:
1175511761
default: 65537
1175611762
description: The table size for
@@ -11767,11 +11773,13 @@ spec:
1176711773
"Header",
1176811774
"Headers",
1176911775
"Cookie".
11776+
"QueryParameter".
1177011777
enum:
1177111778
- SourceIP
1177211779
- Header
1177311780
- Headers
1177411781
- Cookie
11782+
- QueryParameter
1177511783
type: string
1177611784
required:
1177711785
- type
@@ -11792,6 +11800,11 @@ spec:
1179211800
be set.
1179311801
rule: 'self.type == ''Cookie'' ?
1179411802
has(self.cookie) : !has(self.cookie)'
11803+
- message: If consistent hash type
11804+
is queryParameter, the queryParameter
11805+
field must be set.
11806+
rule: 'self.type == ''QueryParameter''
11807+
? has(self.queryParameter) : !has(self.queryParameter)'
1179511808
endpointOverride:
1179611809
description: |-
1179711810
EndpointOverride defines the configuration for endpoint override.
@@ -12958,6 +12971,12 @@ spec:
1295812971
- name
1295912972
type: object
1296012973
type: array
12974+
queryParameter:
12975+
description: QueryParameter configures
12976+
the qery parameter hash policy
12977+
when the consistent hash type
12978+
is set to QueryParameter.
12979+
type: string
1296112980
tableSize:
1296212981
default: 65537
1296312982
description: The table size for
@@ -12974,11 +12993,13 @@ spec:
1297412993
"Header",
1297512994
"Headers",
1297612995
"Cookie".
12996+
"QueryParameter".
1297712997
enum:
1297812998
- SourceIP
1297912999
- Header
1298013000
- Headers
1298113001
- Cookie
13002+
- QueryParameter
1298213003
type: string
1298313004
required:
1298413005
- type
@@ -12999,6 +13020,11 @@ spec:
1299913020
be set.
1300013021
rule: 'self.type == ''Cookie'' ?
1300113022
has(self.cookie) : !has(self.cookie)'
13023+
- message: If consistent hash type
13024+
is queryParameter, the queryParameter
13025+
field must be set.
13026+
rule: 'self.type == ''QueryParameter''
13027+
? has(self.queryParameter) : !has(self.queryParameter)'
1300213028
endpointOverride:
1300313029
description: |-
1300413030
EndpointOverride defines the configuration for endpoint override.
@@ -14257,6 +14283,12 @@ spec:
1425714283
- name
1425814284
type: object
1425914285
type: array
14286+
queryParameter:
14287+
description: QueryParameter configures
14288+
the qery parameter hash policy when
14289+
the consistent hash type is set to
14290+
QueryParameter.
14291+
type: string
1426014292
tableSize:
1426114293
default: 65537
1426214294
description: The table size for consistent
@@ -14273,11 +14305,13 @@ spec:
1427314305
"Header",
1427414306
"Headers",
1427514307
"Cookie".
14308+
"QueryParameter".
1427614309
enum:
1427714310
- SourceIP
1427814311
- Header
1427914312
- Headers
1428014313
- Cookie
14314+
- QueryParameter
1428114315
type: string
1428214316
required:
1428314317
- type
@@ -14295,6 +14329,10 @@ spec:
1429514329
the cookie field must be set.
1429614330
rule: 'self.type == ''Cookie'' ? has(self.cookie)
1429714331
: !has(self.cookie)'
14332+
- message: If consistent hash type is queryParameter,
14333+
the queryParameter field must be set.
14334+
rule: 'self.type == ''QueryParameter''
14335+
? has(self.queryParameter) : !has(self.queryParameter)'
1429814336
endpointOverride:
1429914337
description: |-
1430014338
EndpointOverride defines the configuration for endpoint override.
@@ -15462,6 +15500,11 @@ spec:
1546215500
- name
1546315501
type: object
1546415502
type: array
15503+
queryParameter:
15504+
description: QueryParameter configures the
15505+
qery parameter hash policy when the consistent
15506+
hash type is set to QueryParameter.
15507+
type: string
1546515508
tableSize:
1546615509
default: 65537
1546715510
description: The table size for consistent
@@ -15478,11 +15521,13 @@ spec:
1547815521
"Header",
1547915522
"Headers",
1548015523
"Cookie".
15524+
"QueryParameter".
1548115525
enum:
1548215526
- SourceIP
1548315527
- Header
1548415528
- Headers
1548515529
- Cookie
15530+
- QueryParameter
1548615531
type: string
1548715532
required:
1548815533
- type
@@ -15500,6 +15545,10 @@ spec:
1550015545
the cookie field must be set.
1550115546
rule: 'self.type == ''Cookie'' ? has(self.cookie)
1550215547
: !has(self.cookie)'
15548+
- message: If consistent hash type is queryParameter,
15549+
the queryParameter field must be set.
15550+
rule: 'self.type == ''QueryParameter'' ? has(self.queryParameter)
15551+
: !has(self.queryParameter)'
1550315552
endpointOverride:
1550415553
description: |-
1550515554
EndpointOverride defines the configuration for endpoint override.

0 commit comments

Comments
 (0)