Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduating GEP-726 (Path Redirects and Rewrites) to standard #1874

Merged
merged 1 commit into from
Mar 29, 2023
Merged
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: 2 additions & 13 deletions apis/v1beta1/httproute_types.go
robscott marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ type HTTPRouteFilter struct {
// Reason of `UnsupportedValue`.
//
// +unionDiscriminator
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;ExtensionRef
// +kubebuilder:validation:Enum=RequestHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef
// <gateway:experimental:validation:Enum=RequestHeaderModifier;ResponseHeaderModifier;RequestMirror;RequestRedirect;URLRewrite;ExtensionRef>
Type HTTPRouteFilterType `json:"type"`

Expand Down Expand Up @@ -625,7 +625,6 @@ type HTTPRouteFilter struct {
//
// Support: Extended
//
// <gateway:experimental>
// +optional
URLRewrite *HTTPURLRewriteFilter `json:"urlRewrite,omitempty"`

Expand Down Expand Up @@ -658,6 +657,7 @@ const (
// Support in HTTPRouteRule: Extended
//
// Support in HTTPBackendRef: Extended
//
// <gateway:experimental>
HTTPRouteFilterResponseHeaderModifier HTTPRouteFilterType = "ResponseHeaderModifier"

Expand All @@ -679,8 +679,6 @@ const (
// Support in HTTPRouteRule: Extended
//
// Support in HTTPBackendRef: Extended
//
// <gateway:experimental>
HTTPRouteFilterURLRewrite HTTPRouteFilterType = "URLRewrite"

// HTTPRouteFilterRequestMirror can be used to mirror HTTP requests to a
Expand Down Expand Up @@ -817,7 +815,6 @@ const (
)

// HTTPPathModifier defines configuration for path modifiers.
// <gateway:experimental>
type HTTPPathModifier struct {
// Type defines the type of path modifier. Additional types may be
// added in a future release of the API.
Expand All @@ -829,14 +826,12 @@ type HTTPPathModifier struct {
// Accepted Condition for the Route to `status: False`, with a
// Reason of `UnsupportedValue`.
//
// <gateway:experimental>
// +kubebuilder:validation:Enum=ReplaceFullPath;ReplacePrefixMatch
Type HTTPPathModifierType `json:"type"`

// ReplaceFullPath specifies the value with which to replace the full path
// of a request during a rewrite or redirect.
//
// <gateway:experimental>
// +kubebuilder:validation:MaxLength=1024
// +optional
ReplaceFullPath *string `json:"replaceFullPath,omitempty"`
Expand All @@ -851,7 +846,6 @@ type HTTPPathModifier struct {
// ignored. For example, the paths `/abc`, `/abc/`, and `/abc/def` would all
// match the prefix `/abc`, but the path `/abcd` would not.
//
// <gateway:experimental>
// +kubebuilder:validation:MaxLength=1024
// +optional
ReplacePrefixMatch *string `json:"replacePrefixMatch,omitempty"`
Expand Down Expand Up @@ -892,7 +886,6 @@ type HTTPRequestRedirectFilter struct {
//
// Support: Extended
//
// <gateway:experimental>
// +optional
Path *HTTPPathModifier `json:"path,omitempty"`

Expand Down Expand Up @@ -935,23 +928,19 @@ type HTTPRequestRedirectFilter struct {
// MUST NOT be used on the same Route rule as a HTTPRequestRedirect filter.
//
// Support: Extended
//
// <gateway:experimental>
type HTTPURLRewriteFilter struct {
// Hostname is the value to be used to replace the Host header value during
// forwarding.
//
// Support: Extended
//
// <gateway:experimental>
// +optional
Hostname *PreciseHostname `json:"hostname,omitempty"`

// Path defines a path rewrite.
//
// Support: Extended
//
// <gateway:experimental>
// +optional
Path *HTTPPathModifier `json:"path,omitempty"`
}
Expand Down
118 changes: 52 additions & 66 deletions config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml

Large diffs are not rendered by default.

420 changes: 420 additions & 0 deletions config/crd/standard/gateway.networking.k8s.io_httproutes.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion geps/gep-726.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GEP-726: Add Path Redirects and Rewrites

* Issue: [#726](https://github.com/kubernetes-sigs/gateway-api/issues/726)
* Status: Experimental
* Status: Standard

## TLDR

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ nav:
- geps/gep-1323.md
- geps/gep-1016.md
- geps/gep-957.md
- geps/gep-726.md
- geps/gep-713.md
- Standard:
- geps/gep-1364.md
Expand All @@ -97,6 +96,7 @@ nav:
- geps/gep-851.md
- geps/gep-820.md
- geps/gep-746.md
- geps/gep-726.md
- geps/gep-724.md
- geps/gep-718.md
- geps/gep-709.md
Expand Down
22 changes: 8 additions & 14 deletions site-src/guides/http-redirect-rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use both filter types at once.

## Redirects

Redirects return HTTP 3XX responses to a client, instructing it to retrive a
Redirects return HTTP 3XX responses to a client, instructing it to retrieve a
different resource. [`RequestRedirect` rule
filters](/references/spec/#gateway.networking.k8s.io/v1beta1.HTTPRequestRedirectFilter)
instruct Gateways to emit a redirect response to requests matching a filtered
Expand All @@ -21,7 +21,7 @@ example, to issue a permanent redirect (301) from HTTP to HTTPS, configure
`requestRedirect.statusCode=301` and `requestRedirect.scheme="https"`:

```yaml
{% include 'experimental/http-redirect-rewrite/httproute-redirect-https.yaml' %}
{% include 'standard/http-redirect-rewrite/httproute-redirect-https.yaml' %}
```

Redirects change configured URL components to match the redirect configuration
Expand All @@ -36,15 +36,15 @@ unchanged.
!!! info "Experimental Channel"

The `Path` field described below is currently only included in the
"Experimental" channel of Gateway API. For more information on release
channels, refer to the [related documentation](https://gateway-api.sigs.k8s.io/concepts/versioning).
"Experimental" channel of Gateway API. Starting in v0.7.0, this
feature will graduate to the "Standard" channel.

Path redirects use an HTTP Path Modifier to replace either entire paths or path
prefixes. For example, the HTTPRoute below will issue a 302 redirect to all
`redirect.example` requests whose path begins with `/cayenne` to `/paprika`:

```yaml
{% include 'experimental/http-redirect-rewrite/httproute-redirect-full.yaml' %}
{% include 'standard/http-redirect-rewrite/httproute-redirect-full.yaml' %}
```

Both requests to
Expand All @@ -56,7 +56,7 @@ The other path redirect type, `ReplacePrefixMatch`, replaces only the path
portion matching `matches.path.value`. Changing the filter in the above to:

```yaml
{% include 'experimental/http-redirect-rewrite/httproute-redirect-prefix.yaml' %}
{% include 'standard/http-redirect-rewrite/httproute-redirect-prefix.yaml' %}
```

will result in redirects with `location:
Expand All @@ -65,12 +65,6 @@ https://redirect.example/paprika/teaspoon` response headers.

## Rewrites

!!! info "Experimental Channel"

The `URLRewrite` filter described below is currently only included in the
"Experimental" channel of Gateway API. For more information on release
channels, refer to the [related documentation](https://gateway-api.sigs.k8s.io/concepts/versioning).

Rewrites modify components of a client request before proxying it upstream. A
[`URLRewrite`
filter](/references/spec/#gateway.networking.k8s.io/v1beta1.HTTPURLRewriteFilter)
Expand All @@ -81,7 +75,7 @@ following HTTPRoute will accept a request for
rewrite.example`.

```yaml
{% include 'experimental/http-redirect-rewrite/httproute-rewrite.yaml' %}
{% include 'standard/http-redirect-rewrite/httproute-rewrite.yaml' %}
```

Path rewrites also make use of HTTP Path Modifiers. The HTTPRoute below
Expand All @@ -91,5 +85,5 @@ Instead using `type: ReplacePrefixMatch` and `replacePrefixMatch: /fennel` will
request `https://elsewhere.example/fennel/smidgen` upstream.

```yaml
{% include 'experimental/http-redirect-rewrite/httproute-rewritepath.yaml' %}
{% include 'standard/http-redirect-rewrite/httproute-rewritepath.yaml' %}
```