Skip to content

Commit 45af0ef

Browse files
authored
api: Added support for weighted field in BackendRef (#7452)
* exposed weights in backendRef object and set the same in destination process Signed-off-by: Nayan <[email protected]>
1 parent 4784e5a commit 45af0ef

23 files changed

+2030
-1
lines changed

api/v1alpha1/shared_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,25 @@ type BackendRef struct {
547547
// BackendObjectReference references a Kubernetes object that represents the backend.
548548
// Only Service kind is supported for now.
549549
gwapiv1.BackendObjectReference `json:",inline"`
550+
// Weight specifies the proportion of requests forwarded to the referenced
551+
// backend. This is computed as weight/(sum of all weights in this
552+
// BackendRefs list). For non-zero values, there may be some epsilon from
553+
// the exact proportion defined here depending on the precision an
554+
// implementation supports. Weight is not a percentage and the sum of
555+
// weights does not need to equal 100.
556+
//
557+
// If only one backend is specified and it has a weight greater than 0, 100%
558+
// of the traffic is forwarded to that backend. If weight is set to 0, no
559+
// traffic should be forwarded for this entry. If unspecified, weight
560+
// defaults to 1.
561+
//
562+
// Support for this field varies based on the context where used.
563+
//
564+
// +optional
565+
// +kubebuilder:default=1
566+
// +kubebuilder:validation:Minimum=0
567+
// +kubebuilder:validation:Maximum=1000000
568+
Weight *uint32 `json:"weight,omitempty"`
550569
// Fallback indicates whether the backend is designated as a fallback.
551570
// Multiple fallback backends can be configured.
552571
// It is highly recommended to configure active or passive health checks to ensure that failover can be detected

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_envoyextensionpolicies.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,26 @@ spec:
206206
maximum: 65535
207207
minimum: 1
208208
type: integer
209+
weight:
210+
default: 1
211+
description: |-
212+
Weight specifies the proportion of requests forwarded to the referenced
213+
backend. This is computed as weight/(sum of all weights in this
214+
BackendRefs list). For non-zero values, there may be some epsilon from
215+
the exact proportion defined here depending on the precision an
216+
implementation supports. Weight is not a percentage and the sum of
217+
weights does not need to equal 100.
218+
219+
If only one backend is specified and it has a weight greater than 0, 100%
220+
of the traffic is forwarded to that backend. If weight is set to 0, no
221+
traffic should be forwarded for this entry. If unspecified, weight
222+
defaults to 1.
223+
224+
Support for this field varies based on the context where used.
225+
format: int32
226+
maximum: 1000000
227+
minimum: 0
228+
type: integer
209229
required:
210230
- name
211231
type: object

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11155,6 +11155,26 @@ spec:
1115511155
maximum: 65535
1115611156
minimum: 1
1115711157
type: integer
11158+
weight:
11159+
default: 1
11160+
description: |-
11161+
Weight specifies the proportion of requests forwarded to the referenced
11162+
backend. This is computed as weight/(sum of all weights in this
11163+
BackendRefs list). For non-zero values, there may be some epsilon from
11164+
the exact proportion defined here depending on the precision an
11165+
implementation supports. Weight is not a percentage and the sum of
11166+
weights does not need to equal 100.
11167+
11168+
If only one backend is specified and it has a weight greater than 0, 100%
11169+
of the traffic is forwarded to that backend. If weight is set to 0, no
11170+
traffic should be forwarded for this entry. If unspecified, weight
11171+
defaults to 1.
11172+
11173+
Support for this field varies based on the context where used.
11174+
format: int32
11175+
maximum: 1000000
11176+
minimum: 0
11177+
type: integer
1115811178
required:
1115911179
- name
1116011180
type: object
@@ -12362,6 +12382,26 @@ spec:
1236212382
maximum: 65535
1236312383
minimum: 1
1236412384
type: integer
12385+
weight:
12386+
default: 1
12387+
description: |-
12388+
Weight specifies the proportion of requests forwarded to the referenced
12389+
backend. This is computed as weight/(sum of all weights in this
12390+
BackendRefs list). For non-zero values, there may be some epsilon from
12391+
the exact proportion defined here depending on the precision an
12392+
implementation supports. Weight is not a percentage and the sum of
12393+
weights does not need to equal 100.
12394+
12395+
If only one backend is specified and it has a weight greater than 0, 100%
12396+
of the traffic is forwarded to that backend. If weight is set to 0, no
12397+
traffic should be forwarded for this entry. If unspecified, weight
12398+
defaults to 1.
12399+
12400+
Support for this field varies based on the context where used.
12401+
format: int32
12402+
maximum: 1000000
12403+
minimum: 0
12404+
type: integer
1236512405
required:
1236612406
- name
1236712407
type: object
@@ -13685,6 +13725,26 @@ spec:
1368513725
maximum: 65535
1368613726
minimum: 1
1368713727
type: integer
13728+
weight:
13729+
default: 1
13730+
description: |-
13731+
Weight specifies the proportion of requests forwarded to the referenced
13732+
backend. This is computed as weight/(sum of all weights in this
13733+
BackendRefs list). For non-zero values, there may be some epsilon from
13734+
the exact proportion defined here depending on the precision an
13735+
implementation supports. Weight is not a percentage and the sum of
13736+
weights does not need to equal 100.
13737+
13738+
If only one backend is specified and it has a weight greater than 0, 100%
13739+
of the traffic is forwarded to that backend. If weight is set to 0, no
13740+
traffic should be forwarded for this entry. If unspecified, weight
13741+
defaults to 1.
13742+
13743+
Support for this field varies based on the context where used.
13744+
format: int32
13745+
maximum: 1000000
13746+
minimum: 0
13747+
type: integer
1368813748
required:
1368913749
- name
1369013750
type: object
@@ -14897,6 +14957,26 @@ spec:
1489714957
maximum: 65535
1489814958
minimum: 1
1489914959
type: integer
14960+
weight:
14961+
default: 1
14962+
description: |-
14963+
Weight specifies the proportion of requests forwarded to the referenced
14964+
backend. This is computed as weight/(sum of all weights in this
14965+
BackendRefs list). For non-zero values, there may be some epsilon from
14966+
the exact proportion defined here depending on the precision an
14967+
implementation supports. Weight is not a percentage and the sum of
14968+
weights does not need to equal 100.
14969+
14970+
If only one backend is specified and it has a weight greater than 0, 100%
14971+
of the traffic is forwarded to that backend. If weight is set to 0, no
14972+
traffic should be forwarded for this entry. If unspecified, weight
14973+
defaults to 1.
14974+
14975+
Support for this field varies based on the context where used.
14976+
format: int32
14977+
maximum: 1000000
14978+
minimum: 0
14979+
type: integer
1490014980
required:
1490114981
- name
1490214982
type: object

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,26 @@ spec:
720720
maximum: 65535
721721
minimum: 1
722722
type: integer
723+
weight:
724+
default: 1
725+
description: |-
726+
Weight specifies the proportion of requests forwarded to the referenced
727+
backend. This is computed as weight/(sum of all weights in this
728+
BackendRefs list). For non-zero values, there may be some epsilon from
729+
the exact proportion defined here depending on the precision an
730+
implementation supports. Weight is not a percentage and the sum of
731+
weights does not need to equal 100.
732+
733+
If only one backend is specified and it has a weight greater than 0, 100%
734+
of the traffic is forwarded to that backend. If weight is set to 0, no
735+
traffic should be forwarded for this entry. If unspecified, weight
736+
defaults to 1.
737+
738+
Support for this field varies based on the context where used.
739+
format: int32
740+
maximum: 1000000
741+
minimum: 0
742+
type: integer
723743
required:
724744
- name
725745
type: object
@@ -1817,6 +1837,26 @@ spec:
18171837
maximum: 65535
18181838
minimum: 1
18191839
type: integer
1840+
weight:
1841+
default: 1
1842+
description: |-
1843+
Weight specifies the proportion of requests forwarded to the referenced
1844+
backend. This is computed as weight/(sum of all weights in this
1845+
BackendRefs list). For non-zero values, there may be some epsilon from
1846+
the exact proportion defined here depending on the precision an
1847+
implementation supports. Weight is not a percentage and the sum of
1848+
weights does not need to equal 100.
1849+
1850+
If only one backend is specified and it has a weight greater than 0, 100%
1851+
of the traffic is forwarded to that backend. If weight is set to 0, no
1852+
traffic should be forwarded for this entry. If unspecified, weight
1853+
defaults to 1.
1854+
1855+
Support for this field varies based on the context where used.
1856+
format: int32
1857+
maximum: 1000000
1858+
minimum: 0
1859+
type: integer
18201860
required:
18211861
- name
18221862
type: object
@@ -3110,6 +3150,26 @@ spec:
31103150
maximum: 65535
31113151
minimum: 1
31123152
type: integer
3153+
weight:
3154+
default: 1
3155+
description: |-
3156+
Weight specifies the proportion of requests forwarded to the referenced
3157+
backend. This is computed as weight/(sum of all weights in this
3158+
BackendRefs list). For non-zero values, there may be some epsilon from
3159+
the exact proportion defined here depending on the precision an
3160+
implementation supports. Weight is not a percentage and the sum of
3161+
weights does not need to equal 100.
3162+
3163+
If only one backend is specified and it has a weight greater than 0, 100%
3164+
of the traffic is forwarded to that backend. If weight is set to 0, no
3165+
traffic should be forwarded for this entry. If unspecified, weight
3166+
defaults to 1.
3167+
3168+
Support for this field varies based on the context where used.
3169+
format: int32
3170+
maximum: 1000000
3171+
minimum: 0
3172+
type: integer
31133173
required:
31143174
- name
31153175
type: object
@@ -4491,6 +4551,26 @@ spec:
44914551
maximum: 65535
44924552
minimum: 1
44934553
type: integer
4554+
weight:
4555+
default: 1
4556+
description: |-
4557+
Weight specifies the proportion of requests forwarded to the referenced
4558+
backend. This is computed as weight/(sum of all weights in this
4559+
BackendRefs list). For non-zero values, there may be some epsilon from
4560+
the exact proportion defined here depending on the precision an
4561+
implementation supports. Weight is not a percentage and the sum of
4562+
weights does not need to equal 100.
4563+
4564+
If only one backend is specified and it has a weight greater than 0, 100%
4565+
of the traffic is forwarded to that backend. If weight is set to 0, no
4566+
traffic should be forwarded for this entry. If unspecified, weight
4567+
defaults to 1.
4568+
4569+
Support for this field varies based on the context where used.
4570+
format: int32
4571+
maximum: 1000000
4572+
minimum: 0
4573+
type: integer
44944574
required:
44954575
- name
44964576
type: object

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,26 @@ spec:
205205
maximum: 65535
206206
minimum: 1
207207
type: integer
208+
weight:
209+
default: 1
210+
description: |-
211+
Weight specifies the proportion of requests forwarded to the referenced
212+
backend. This is computed as weight/(sum of all weights in this
213+
BackendRefs list). For non-zero values, there may be some epsilon from
214+
the exact proportion defined here depending on the precision an
215+
implementation supports. Weight is not a percentage and the sum of
216+
weights does not need to equal 100.
217+
218+
If only one backend is specified and it has a weight greater than 0, 100%
219+
of the traffic is forwarded to that backend. If weight is set to 0, no
220+
traffic should be forwarded for this entry. If unspecified, weight
221+
defaults to 1.
222+
223+
Support for this field varies based on the context where used.
224+
format: int32
225+
maximum: 1000000
226+
minimum: 0
227+
type: integer
208228
required:
209229
- name
210230
type: object

0 commit comments

Comments
 (0)