@@ -152,12 +152,15 @@ type HTTPRouteRule struct {
152
152
//
153
153
// * The oldest Route based on creation timestamp.
154
154
// * The Route appearing first in alphabetical order by
155
- // "< namespace>/< name> ".
155
+ // "{ namespace}/{ name} ".
156
156
//
157
157
// If ties still exist within the Route that has been given precedence,
158
158
// matching precedence MUST be granted to the first matching rule meeting
159
159
// the above criteria.
160
160
//
161
+ // When no rules matching a request have been successfully attached to the
162
+ // parent a request is coming from, a HTTP 404 status code MUST be returned.
163
+ //
161
164
// +optional
162
165
// +kubebuilder:validation:MaxItems=8
163
166
// +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}}
@@ -187,13 +190,25 @@ type HTTPRouteRule struct {
187
190
188
191
// BackendRefs defines the backend(s) where matching requests should be
189
192
// sent.
190
-
191
- // If unspecified or invalid (refers to a non-existent resource or a Service
192
- // with no endpoints), the rule performs no forwarding. If there are also no
193
- // filters specified that would result in a response being sent, a HTTP 503
194
- // status code is returned. 503 responses must be sent so that the overall
195
- // weight is respected; if an invalid backend is requested to have 80% of
196
- // requests, then 80% of requests must get a 503 instead.
193
+ //
194
+ // A 404 status code MUST be returned if there are no BackendRefs or filters
195
+ // specified that would result in a response being sent.
196
+ //
197
+ // A BackendRef is considered invalid when it refers to:
198
+ //
199
+ // * an unknown or unsupported kind of resource
200
+ // * a resource that does not exist
201
+ // * a resource in another namespace when the reference has not been
202
+ // explicitly allowed by a ReferencePolicy (or equivalent concept).
203
+ //
204
+ // When a BackendRef is invalid, 404 status codes MUST be returned for
205
+ // requests that would have otherwise been routed to an invalid backend. If
206
+ // multiple backends are specified, and some are invalid, the proportion of
207
+ // requests that would otherwise have been routed to an invalid backend
208
+ // MUST receive a 404 status code.
209
+ //
210
+ // When a BackendRef refers to a Service that has no ready endpoints, it is
211
+ // recommended to return a 503 status code.
197
212
//
198
213
// Support: Core for Kubernetes Service
199
214
// Support: Custom for any other resource
@@ -227,11 +242,10 @@ const (
227
242
// Matches based on a URL path prefix split by `/`. Matching is
228
243
// case sensitive and done on a path element by element basis. A
229
244
// path element refers to the list of labels in the path split by
230
- // the `/` separator. A request is a match for path _p_ if every
231
- // _p_ is an element-wise prefix of the request path.
245
+ // the `/` separator. When specified, a trailing `/` is ignored.
232
246
//
233
- // For example, `/abc`, `/abc/` and `/abc/def` match the prefix
234
- // `/abc`, but `/abcd` does not.
247
+ // For example. the paths `/abc`, `/abc/`, and `/abc/def` would all match
248
+ // the prefix `/abc`, but the path `/abcd` would not.
235
249
//
236
250
// "PathPrefix" is semantically equivalent to the "Prefix" path type in the
237
251
// Kubernetes Ingress API.
@@ -495,6 +509,8 @@ type HTTPRouteFilter struct {
495
509
// that filter MUST receive a HTTP error response.
496
510
//
497
511
// +unionDiscriminator
512
+ // +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
513
+ // <gateway:experimental:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
498
514
Type HTTPRouteFilterType `json:"type"`
499
515
500
516
// RequestHeaderModifier defines a schema for a filter that modifies request
@@ -522,6 +538,13 @@ type HTTPRouteFilter struct {
522
538
// +optional
523
539
RequestRedirect * HTTPRequestRedirectFilter `json:"requestRedirect,omitempty"`
524
540
541
+ // URLRewrite defines a schema for a filter that modifies a request during forwarding.
542
+ // Support: Extended
543
+ //
544
+ // <gateway:experimental>
545
+ // +optional
546
+ URLRewrite * HTTPURLRewriteFilter `json:"urlRewrite,omitempty"`
547
+
525
548
// ExtensionRef is an optional, implementation-specific extension to the
526
549
// "filter" behavior. For example, resource "myroutefilter" in group
527
550
// "networking.example.net"). ExtensionRef MUST NOT be used for core and
@@ -534,7 +557,6 @@ type HTTPRouteFilter struct {
534
557
}
535
558
536
559
// HTTPRouteFilterType identifies a type of HTTPRoute filter.
537
- // +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
538
560
type HTTPRouteFilterType string
539
561
540
562
const (
@@ -548,13 +570,26 @@ const (
548
570
549
571
// HTTPRouteFilterRequestRedirect can be used to redirect a request to
550
572
// another location. This filter can also be used for HTTP to HTTPS
551
- // redirects.
573
+ // redirects. This may not be used on the same Route rule or BackendRef as a
574
+ // URLRewrite filter.
552
575
//
553
576
// Support in HTTPRouteRule: Core
554
577
//
555
578
// Support in HTTPBackendRef: Extended
556
579
HTTPRouteFilterRequestRedirect HTTPRouteFilterType = "RequestRedirect"
557
580
581
+ // HTTPRouteFilterURLRewrite can be used to modify a request during
582
+ // forwarding. At most one of these filters may be used on a Route rule.
583
+ // This may not be used on the same Route rule or BackendRef as a
584
+ // RequestRedirect filter.
585
+ //
586
+ // Support in HTTPRouteRule: Extended
587
+ //
588
+ // Support in HTTPBackendRef: Extended
589
+ //
590
+ // <gateway:experimental>
591
+ HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"
592
+
558
593
// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
559
594
// different backend. The responses from this backend MUST be ignored by
560
595
// the Gateway.
@@ -664,7 +699,42 @@ type HTTPRequestHeaderFilter struct {
664
699
Remove []string `json:"remove,omitempty"`
665
700
}
666
701
667
- // HTTPRequestRedirectFilter defines configuration for the RequestRedirect filter.
702
+ // HTTPPathModifierType defines the type of path redirect.
703
+ type HTTPPathModifierType string
704
+
705
+ const (
706
+ // This type of modifier indicates that the complete path will be replaced
707
+ // by the path redirect value.
708
+ AbsoluteHTTPPathModifier HTTPPathModifierType = "Absolute"
709
+
710
+ // This type of modifier indicates that any prefix path matches will be
711
+ // replaced by the substitution value. For example, a path with a prefix
712
+ // match of "/foo" and a ReplacePrefixMatch substitution of "/bar" will have
713
+ // the "/foo" prefix replaced with "/bar" in matching requests.
714
+ PrefixMatchHTTPPathModifier HTTPPathModifierType = "ReplacePrefixMatch"
715
+ )
716
+
717
+ // HTTPPathModifier defines configuration for path modifiers.
718
+ // <gateway:experimental>
719
+ type HTTPPathModifier struct {
720
+ // Type defines the type of path modifier.
721
+ //
722
+ // <gateway:experimental>
723
+ // +kubebuilder:validation:Enum=Absolute;ReplacePrefixMatch
724
+ Type HTTPPathModifierType `json:"type"`
725
+
726
+ // Substitution defines the HTTP path value to substitute. An empty value
727
+ // ("") indicates that the portion of the path to be changed should be
728
+ // removed from the resulting path. For example, a request to "/foo/bar"
729
+ // with a prefix match of "/foo" would be modified to "/bar".
730
+ //
731
+ // <gateway:experimental>
732
+ // +kubebuilder:validation:MaxLength=1024
733
+ Substitution string `json:"substitution"`
734
+ }
735
+
736
+ // HTTPRequestRedirect defines a filter that redirects a request. This filter
737
+ // MUST not be used on the same Route rule as a HTTPURLRewrite filter.
668
738
type HTTPRequestRedirectFilter struct {
669
739
// Scheme is the scheme to be used in the value of the `Location`
670
740
// header in the response.
@@ -685,6 +755,16 @@ type HTTPRequestRedirectFilter struct {
685
755
// +optional
686
756
Hostname * PreciseHostname `json:"hostname,omitempty"`
687
757
758
+ // Path defines parameters used to modify the path of the incoming request.
759
+ // The modified path is then used to construct the `Location` header. When
760
+ // empty, the request path is used as-is.
761
+ //
762
+ // Support: Extended
763
+ //
764
+ // <gateway:experimental>
765
+ // +optional
766
+ Path * HTTPPathModifier `json:"path,omitempty"`
767
+
688
768
// Port is the port to be used in the value of the `Location`
689
769
// header in the response.
690
770
// When empty, port (if specified) of the request is used.
@@ -704,6 +784,31 @@ type HTTPRequestRedirectFilter struct {
704
784
StatusCode * int `json:"statusCode,omitempty"`
705
785
}
706
786
787
+ // HTTPURLRewriteFilter defines a filter that modifies a request during
788
+ // forwarding. At most one of these filters may be used on a Route rule. This
789
+ // may not be used on the same Route rule as a HTTPRequestRedirect filter.
790
+ //
791
+ // <gateway:experimental>
792
+ // Support: Extended
793
+ type HTTPURLRewriteFilter struct {
794
+ // Hostname is the value to be used to replace the Host header value during
795
+ // forwarding.
796
+ //
797
+ // Support: Extended
798
+ //
799
+ // <gateway:experimental>
800
+ // +optional
801
+ Hostname * Hostname `json:"hostname,omitempty"`
802
+
803
+ // Path defines a path rewrite.
804
+ //
805
+ // Support: Extended
806
+ //
807
+ // <gateway:experimental>
808
+ // +optional
809
+ Path * HTTPPathModifier `json:"path,omitempty"`
810
+ }
811
+
707
812
// HTTPRequestMirrorFilter defines configuration for the RequestMirror filter.
708
813
type HTTPRequestMirrorFilter struct {
709
814
// BackendRef references a resource where mirrored requests are sent.
@@ -738,7 +843,7 @@ type HTTPBackendRef struct {
738
843
//
739
844
// If there is a cross-namespace reference to an *existing* object
740
845
// that is not covered by a ReferencePolicy, the controller must ensure the
741
- // "ResolvedRefs" condition on the Route is set to `status: true `,
846
+ // "ResolvedRefs" condition on the Route is set to `status: False `,
742
847
// with the "RefNotPermitted" reason and not configure this backend in the
743
848
// underlying implementation.
744
849
//
0 commit comments