Skip to content

Commit 7c3e11b

Browse files
authored
feat: support listenerset policy attach in backend traffic policy (#9419)
* feat: backend traffic policy listenerset attach Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * add release note Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update docs Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * fix e2e testfile Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> * update latest code Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com> --------- Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
1 parent e2ab612 commit 7c3e11b

33 files changed

Lines changed: 5484 additions & 343 deletions

File tree

api/v1alpha1/backendtrafficpolicy_types.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,22 @@ type BackendTrafficPolicy struct {
4040
//
4141
// +kubebuilder:validation:XValidation:rule="(has(self.targetRef) && !has(self.targetRefs)) || (!has(self.targetRef) && has(self.targetRefs)) || (has(self.targetSelectors) && self.targetSelectors.size() > 0) ", message="either targetRef or targetRefs must be used"
4242
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.group == 'gateway.networking.k8s.io' : true ", message="this policy can only have a targetRef.group of gateway.networking.k8s.io"
43-
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute"
43+
// +kubebuilder:validation:XValidation:rule="has(self.targetRef) ? self.targetRef.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute'] : true", message="this policy can only have a targetRef.kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute"
4444
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.group == 'gateway.networking.k8s.io') : true ", message="this policy can only have a targetRefs[*].group of gateway.networking.k8s.io"
45-
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute"
45+
// +kubebuilder:validation:XValidation:rule="has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute']) : true ", message="this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute"
46+
// +kubebuilder:validation:XValidation:rule="!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind in ['HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['HTTPRoute', 'GRPCRoute', 'UDPRoute', 'TCPRoute', 'TLSRoute'])))", message="mergeType can only be used with xRoute targets"
4647
// +kubebuilder:validation:XValidation:rule="!has(self.compression) || !has(self.compressor)", message="either compression or compressor can be set, not both"
4748
// +kubebuilder:validation:XValidation:rule="!has(self.requestBuffer) || !has(self.httpUpgrade) || self.httpUpgrade.size() == 0", message="requestBuffer cannot be used together with httpUpgrade"
48-
// +kubebuilder:validation:XValidation:rule="!has(self.admissionControl) || ((!has(self.targetRef) || self.targetRef.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['Gateway', 'HTTPRoute', 'GRPCRoute'])))", message="admissionControl can only be used with HTTPRoute, GRPCRoute, or Gateway targets"
49+
// +kubebuilder:validation:XValidation:rule="!has(self.admissionControl) || ((!has(self.targetRef) || self.targetRef.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute']) && (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute'])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind in ['Gateway', 'ListenerSet', 'HTTPRoute', 'GRPCRoute'])))", message="admissionControl can only be used with HTTPRoute, GRPCRoute, Gateway, or ListenerSet targets"
4950
type BackendTrafficPolicySpec struct {
5051
PolicyTargetReferences `json:",inline"`
5152
ClusterSettings `json:",inline"`
5253

5354
// MergeType determines how this configuration is merged with existing BackendTrafficPolicy
5455
// configurations targeting a parent resource. When set, this configuration will be merged
55-
// into a parent BackendTrafficPolicy (i.e. the one targeting a Gateway or Listener).
56-
// This field cannot be set when targeting a parent resource (Gateway).
56+
// into the closest parent BackendTrafficPolicy in the route's attachment hierarchy (for
57+
// example, one targeting a Gateway, Gateway listener, ListenerSet, or ListenerSet listener).
58+
// Currently, this field can only be set when targeting xRoute resources.
5759
// If unset, no merging occurs, and only the most specific configuration takes effect.
5860
//
5961
// +kubebuilder:validation:XValidation:rule="self != 'Replace'",message="Replace is not a valid MergeType for BackendTrafficPolicySpec"

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,8 +1465,9 @@ spec:
14651465
description: |-
14661466
MergeType determines how this configuration is merged with existing BackendTrafficPolicy
14671467
configurations targeting a parent resource. When set, this configuration will be merged
1468-
into a parent BackendTrafficPolicy (i.e. the one targeting a Gateway or Listener).
1469-
This field cannot be set when targeting a parent resource (Gateway).
1468+
into the closest parent BackendTrafficPolicy in the route's attachment hierarchy (for
1469+
example, one targeting a Gateway, Gateway listener, ListenerSet, or ListenerSet listener).
1470+
Currently, this field can only be set when targeting xRoute resources.
14701471
If unset, no merging occurs, and only the most specific configuration takes effect.
14711472
type: string
14721473
x-kubernetes-validations:
@@ -3407,28 +3408,37 @@ spec:
34073408
- message: this policy can only have a targetRef.group of gateway.networking.k8s.io
34083409
rule: 'has(self.targetRef) ? self.targetRef.group == ''gateway.networking.k8s.io''
34093410
: true '
3410-
- message: this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3411-
rule: 'has(self.targetRef) ? self.targetRef.kind in [''Gateway'', ''HTTPRoute'',
3412-
''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''] : true'
3411+
- message: this policy can only have a targetRef.kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3412+
rule: 'has(self.targetRef) ? self.targetRef.kind in [''Gateway'', ''ListenerSet'',
3413+
''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute'']
3414+
: true'
34133415
- message: this policy can only have a targetRefs[*].group of gateway.networking.k8s.io
34143416
rule: 'has(self.targetRefs) ? self.targetRefs.all(ref, ref.group ==
34153417
''gateway.networking.k8s.io'') : true '
3416-
- message: this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3418+
- message: this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
34173419
rule: 'has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in [''Gateway'',
3418-
''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])
3419-
: true '
3420+
''ListenerSet'', ''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'',
3421+
''TLSRoute'']) : true '
3422+
- message: mergeType can only be used with xRoute targets
3423+
rule: '!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind
3424+
in [''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])
3425+
&& (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in
3426+
[''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute'']))
3427+
&& (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind
3428+
in [''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])))'
34203429
- message: either compression or compressor can be set, not both
34213430
rule: '!has(self.compression) || !has(self.compressor)'
34223431
- message: requestBuffer cannot be used together with httpUpgrade
34233432
rule: '!has(self.requestBuffer) || !has(self.httpUpgrade) || self.httpUpgrade.size()
34243433
== 0'
34253434
- message: admissionControl can only be used with HTTPRoute, GRPCRoute,
3426-
or Gateway targets
3435+
Gateway, or ListenerSet targets
34273436
rule: '!has(self.admissionControl) || ((!has(self.targetRef) || self.targetRef.kind
3428-
in [''Gateway'', ''HTTPRoute'', ''GRPCRoute'']) && (!has(self.targetRefs)
3429-
|| self.targetRefs.all(ref, ref.kind in [''Gateway'', ''HTTPRoute'',
3430-
''GRPCRoute''])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel,
3431-
sel.kind in [''Gateway'', ''HTTPRoute'', ''GRPCRoute''])))'
3437+
in [''Gateway'', ''ListenerSet'', ''HTTPRoute'', ''GRPCRoute'']) &&
3438+
(!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in [''Gateway'',
3439+
''ListenerSet'', ''HTTPRoute'', ''GRPCRoute''])) && (!has(self.targetSelectors)
3440+
|| self.targetSelectors.all(sel, sel.kind in [''Gateway'', ''ListenerSet'',
3441+
''HTTPRoute'', ''GRPCRoute''])))'
34323442
- message: predictivePercent in preconnect policy only works with RoundRobin
34333443
or Random load balancers
34343444
rule: '!((has(self.connection) && has(self.connection.preconnect) &&

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,8 +1464,9 @@ spec:
14641464
description: |-
14651465
MergeType determines how this configuration is merged with existing BackendTrafficPolicy
14661466
configurations targeting a parent resource. When set, this configuration will be merged
1467-
into a parent BackendTrafficPolicy (i.e. the one targeting a Gateway or Listener).
1468-
This field cannot be set when targeting a parent resource (Gateway).
1467+
into the closest parent BackendTrafficPolicy in the route's attachment hierarchy (for
1468+
example, one targeting a Gateway, Gateway listener, ListenerSet, or ListenerSet listener).
1469+
Currently, this field can only be set when targeting xRoute resources.
14691470
If unset, no merging occurs, and only the most specific configuration takes effect.
14701471
type: string
14711472
x-kubernetes-validations:
@@ -3406,28 +3407,37 @@ spec:
34063407
- message: this policy can only have a targetRef.group of gateway.networking.k8s.io
34073408
rule: 'has(self.targetRef) ? self.targetRef.group == ''gateway.networking.k8s.io''
34083409
: true '
3409-
- message: this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3410-
rule: 'has(self.targetRef) ? self.targetRef.kind in [''Gateway'', ''HTTPRoute'',
3411-
''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''] : true'
3410+
- message: this policy can only have a targetRef.kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3411+
rule: 'has(self.targetRef) ? self.targetRef.kind in [''Gateway'', ''ListenerSet'',
3412+
''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute'']
3413+
: true'
34123414
- message: this policy can only have a targetRefs[*].group of gateway.networking.k8s.io
34133415
rule: 'has(self.targetRefs) ? self.targetRefs.all(ref, ref.group ==
34143416
''gateway.networking.k8s.io'') : true '
3415-
- message: this policy can only have a targetRefs[*].kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
3417+
- message: this policy can only have a targetRefs[*].kind of Gateway/ListenerSet/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute
34163418
rule: 'has(self.targetRefs) ? self.targetRefs.all(ref, ref.kind in [''Gateway'',
3417-
''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])
3418-
: true '
3419+
''ListenerSet'', ''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'',
3420+
''TLSRoute'']) : true '
3421+
- message: mergeType can only be used with xRoute targets
3422+
rule: '!has(self.mergeType) || ((!has(self.targetRef) || self.targetRef.kind
3423+
in [''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])
3424+
&& (!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in
3425+
[''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute'']))
3426+
&& (!has(self.targetSelectors) || self.targetSelectors.all(sel, sel.kind
3427+
in [''HTTPRoute'', ''GRPCRoute'', ''UDPRoute'', ''TCPRoute'', ''TLSRoute''])))'
34193428
- message: either compression or compressor can be set, not both
34203429
rule: '!has(self.compression) || !has(self.compressor)'
34213430
- message: requestBuffer cannot be used together with httpUpgrade
34223431
rule: '!has(self.requestBuffer) || !has(self.httpUpgrade) || self.httpUpgrade.size()
34233432
== 0'
34243433
- message: admissionControl can only be used with HTTPRoute, GRPCRoute,
3425-
or Gateway targets
3434+
Gateway, or ListenerSet targets
34263435
rule: '!has(self.admissionControl) || ((!has(self.targetRef) || self.targetRef.kind
3427-
in [''Gateway'', ''HTTPRoute'', ''GRPCRoute'']) && (!has(self.targetRefs)
3428-
|| self.targetRefs.all(ref, ref.kind in [''Gateway'', ''HTTPRoute'',
3429-
''GRPCRoute''])) && (!has(self.targetSelectors) || self.targetSelectors.all(sel,
3430-
sel.kind in [''Gateway'', ''HTTPRoute'', ''GRPCRoute''])))'
3436+
in [''Gateway'', ''ListenerSet'', ''HTTPRoute'', ''GRPCRoute'']) &&
3437+
(!has(self.targetRefs) || self.targetRefs.all(ref, ref.kind in [''Gateway'',
3438+
''ListenerSet'', ''HTTPRoute'', ''GRPCRoute''])) && (!has(self.targetSelectors)
3439+
|| self.targetSelectors.all(sel, sel.kind in [''Gateway'', ''ListenerSet'',
3440+
''HTTPRoute'', ''GRPCRoute''])))'
34313441
- message: predictivePercent in preconnect policy only works with RoundRobin
34323442
or Random load balancers
34333443
rule: '!((has(self.connection) && has(self.connection.preconnect) &&

0 commit comments

Comments
 (0)