Skip to content
Open
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
15 changes: 14 additions & 1 deletion api/v1alpha1/loadbalancer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,25 @@ const (
RoundRobinLoadBalancerType LoadBalancerType = "RoundRobin"
)

// QueryParamName defines the query parameter name hashing configuration for consistent hash based
// load balancing.
type QueryParam string
Copy link
Member

Choose a reason for hiding this comment

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

should we reuse the struct from gwapi?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you give a link to struct?

Copy link
Contributor

Choose a reason for hiding this comment

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

upstream only has a match type definition , so this definition works


// ConsistentHash defines the configuration related to the consistent hash
// load balancer policy.
// +union
//
// +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."
// +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."
// +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."
// +kubebuilder:validation:XValidation:rule="self.type == 'QueryParam' ? has(self.queryParam) : !has(self.queryParam)",message="If consistent hash type is queryParam, the queryParam field must be set."
type ConsistentHash struct {
// ConsistentHashType defines the type of input to hash on. Valid Type values are
// "SourceIP",
// "Header",
// "Headers",
// "Cookie".
// "QueryParam".
//
// +unionDiscriminator
Type ConsistentHashType `json:"type"`
Expand All @@ -98,6 +104,11 @@ type ConsistentHash struct {
// +optional
Cookie *Cookie `json:"cookie,omitempty"`

// QueryParam configures the query parameter hash policy when the consistent hash type is set to QueryParam.
//
// +optional
QueryParam *QueryParam `json:"queryParam,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

should be QueryParams similar to Headers ( we deprecated Header)


// The table size for consistent hashing, must be prime number limited to 5000011.
//
// +kubebuilder:validation:Minimum=2
Expand Down Expand Up @@ -135,7 +146,7 @@ type Cookie struct {
}

// ConsistentHashType defines the type of input to hash on.
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie
// +kubebuilder:validation:Enum=SourceIP;Header;Headers;Cookie;QueryParam
type ConsistentHashType string

const (
Expand All @@ -149,6 +160,8 @@ const (
HeadersConsistentHashType ConsistentHashType = "Headers"
// CookieConsistentHashType hashes based on a cookie.
CookieConsistentHashType ConsistentHashType = "Cookie"
// QueryParamConsistentHashType hashes based on a query parameter.
QueryParamConsistentHashType ConsistentHashType = "QueryParam"
)

// SlowStart defines the configuration related to the slow start load balancer policy.
Expand Down
5 changes: 5 additions & 0 deletions api/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 @@ -736,6 +736,10 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures the query parameter hash
policy when the consistent hash type is set to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for consistent hashing, must be
Expand All @@ -751,11 +755,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -770,6 +776,10 @@ spec:
- message: If consistent hash type is cookie, the cookie field
must be set.
rule: 'self.type == ''Cookie'' ? has(self.cookie) : !has(self.cookie)'
- message: If consistent hash type is queryParam, the queryParam
field must be set.
rule: 'self.type == ''QueryParam'' ? has(self.queryParam) :
!has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,11 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures the query parameter
hash policy when the consistent hash type is set
to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for consistent hashing,
Expand All @@ -791,11 +796,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -813,6 +820,10 @@ spec:
field must be set.
rule: 'self.type == ''Cookie'' ? has(self.cookie)
: !has(self.cookie)'
- message: If consistent hash type is queryParam, the
queryParam field must be set.
rule: 'self.type == ''QueryParam'' ? has(self.queryParam)
: !has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11751,6 +11751,12 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures
the query parameter hash policy
when the consistent hash type
is set to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for
Expand All @@ -11767,11 +11773,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -11792,6 +11800,11 @@ spec:
be set.
rule: 'self.type == ''Cookie'' ?
has(self.cookie) : !has(self.cookie)'
- message: If consistent hash type
is queryParam, the queryParam
field must be set.
rule: 'self.type == ''QueryParam''
? has(self.queryParam) : !has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down Expand Up @@ -12958,6 +12971,12 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures
the query parameter hash policy
when the consistent hash type
is set to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for
Expand All @@ -12974,11 +12993,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -12999,6 +13020,11 @@ spec:
be set.
rule: 'self.type == ''Cookie'' ?
has(self.cookie) : !has(self.cookie)'
- message: If consistent hash type
is queryParam, the queryParam
field must be set.
rule: 'self.type == ''QueryParam''
? has(self.queryParam) : !has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down Expand Up @@ -14257,6 +14283,11 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures the
query parameter hash policy when the
consistent hash type is set to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for consistent
Expand All @@ -14273,11 +14304,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -14295,6 +14328,10 @@ spec:
the cookie field must be set.
rule: 'self.type == ''Cookie'' ? has(self.cookie)
: !has(self.cookie)'
- message: If consistent hash type is queryParam,
the queryParam field must be set.
rule: 'self.type == ''QueryParam'' ? has(self.queryParam)
: !has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down Expand Up @@ -15462,6 +15499,11 @@ spec:
- name
type: object
type: array
queryParam:
description: QueryParam configures the query
parameter hash policy when the consistent
hash type is set to QueryParam.
type: string
tableSize:
default: 65537
description: The table size for consistent
Expand All @@ -15478,11 +15520,13 @@ spec:
"Header",
"Headers",
"Cookie".
"QueryParam".
enum:
- SourceIP
- Header
- Headers
- Cookie
- QueryParam
type: string
required:
- type
Expand All @@ -15500,6 +15544,10 @@ spec:
the cookie field must be set.
rule: 'self.type == ''Cookie'' ? has(self.cookie)
: !has(self.cookie)'
- message: If consistent hash type is queryParam,
the queryParam field must be set.
rule: 'self.type == ''QueryParam'' ? has(self.queryParam)
: !has(self.queryParam)'
endpointOverride:
description: |-
EndpointOverride defines the configuration for endpoint override.
Expand Down
Loading