1
0
Fork 0

feat: add highest random weight in kubernetes CRD

This commit is contained in:
Landry Benguigui 2025-09-19 10:18:04 +02:00 committed by GitHub
parent c09d3fb03c
commit 634f892370
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1328 additions and 24 deletions

View file

@ -114,10 +114,10 @@ type LoadBalancerSpec struct {
// It defaults to https when Kubernetes Service port is 443, http otherwise.
Scheme string `json:"scheme,omitempty"`
// Strategy defines the load balancing strategy between the servers.
// Supported values are: wrr (Weighed round-robin) and p2c (Power of two choices).
// Supported values are: wrr (Weighed round-robin), p2c (Power of two choices), and hrw (Highest Random Weight).
// RoundRobin value is deprecated and supported for backward compatibility.
// TODO: when the deprecated RoundRobin value will be removed, set the default value to wrr.
// +kubebuilder:validation:Enum=wrr;p2c;RoundRobin
// +kubebuilder:validation:Enum=wrr;p2c;hrw;RoundRobin
Strategy dynamic.BalancerStrategy `json:"strategy,omitempty"`
// PassHostHeader defines whether the client Host header is forwarded to the upstream Kubernetes Service.
// By default, passHostHeader is true.

View file

@ -44,6 +44,8 @@ type TraefikServiceSpec struct {
Weighted *WeightedRoundRobin `json:"weighted,omitempty"`
// Mirroring defines the Mirroring service configuration.
Mirroring *Mirroring `json:"mirroring,omitempty"`
// HighestRandomWeight defines the highest random weight service configuration.
HighestRandomWeight *HighestRandomWeight `json:"highestRandomWeight,omitempty"`
}
// +k8s:deepcopy-gen=true
@ -86,3 +88,12 @@ type WeightedRoundRobin struct {
// More info: https://doc.traefik.io/traefik/v3.5/routing/providers/kubernetes-crd/#stickiness-and-load-balancing
Sticky *dynamic.Sticky `json:"sticky,omitempty"`
}
// +k8s:deepcopy-gen=true
// HighestRandomWeight holds the highest random weight configuration.
// More info: https://doc.traefik.io/traefik/v3.5/routing/services/#highest-random-configuration
type HighestRandomWeight struct {
// Services defines the list of Kubernetes Service and/or TraefikService to load-balance, with weight.
Services []Service `json:"services,omitempty"`
}

View file

@ -349,6 +349,29 @@ func (in *ForwardingTimeouts) DeepCopy() *ForwardingTimeouts {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HighestRandomWeight) DeepCopyInto(out *HighestRandomWeight) {
*out = *in
if in.Services != nil {
in, out := &in.Services, &out.Services
*out = make([]Service, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HighestRandomWeight.
func (in *HighestRandomWeight) DeepCopy() *HighestRandomWeight {
if in == nil {
return nil
}
out := new(HighestRandomWeight)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IngressRoute) DeepCopyInto(out *IngressRoute) {
*out = *in
@ -2028,6 +2051,11 @@ func (in *TraefikServiceSpec) DeepCopyInto(out *TraefikServiceSpec) {
*out = new(Mirroring)
(*in).DeepCopyInto(*out)
}
if in.HighestRandomWeight != nil {
in, out := &in.HighestRandomWeight, &out.HighestRandomWeight
*out = new(HighestRandomWeight)
(*in).DeepCopyInto(*out)
}
return
}