Skip to content

Conversation

@muxanasov
Copy link

@muxanasov muxanasov commented Dec 17, 2025

What type of PR is this?
/kind documentation

What this PR does / why we need it:
This is to create a new GEP

Does this PR introduce a user-facing change?:
No

@k8s-ci-robot k8s-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Dec 17, 2025
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 17, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 17, 2025
@k8s-ci-robot k8s-ci-robot added the kind/gep PRs related to Gateway Enhancement Proposal(GEP) label Dec 17, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @muxanasov!

It looks like this is your first PR to kubernetes-sigs/gateway-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gateway-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 17, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @muxanasov. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @muxanasov!


## Goals

Close the feature gap for Gateway API.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just closing the feature gap, I'd recommend focusing on the specific capabilities you want to express with the API, such as:

  • Rewrite the path of a request based on a regular expression, regardless of initial match type
  • Substitute matching section(s) in the regular expression with predefined values

On point 2, I'm not sure if the goal is to substitute multiple or just a single match, and how the substitution should be formatted - multiple inputs or just one?

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 19, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Dec 19, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: muxanasov
Once this PR has been reviewed and has the lgtm label, please assign aojea for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@muxanasov muxanasov requested a review from robscott December 19, 2025 09:39
@robscott
Copy link
Member

/release-note-none
/ok-to-test

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 20, 2025

## New Fields relationship

The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation.
The relationship between new fields should be consistent across different underlying implementations and dataplanes. The syntax, however, may vary depending on the implementation.

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


While relationship between pattern and substitution are invariant across implementaitons, the regex syntax is implemntation scpeific.

Here we show examples that use Google's [RE2](https://github.com/google/re2) engine and should work in Envoy's [regex_rewrite](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-field-config-route-v3-routeaction-regex-rewrite).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you write a conformance test plan, I'd recommend suggesting that we find a way to configure the regex format, and then ensuring that the conformance tests are written in a way that they can support multiple formats. We could start with RE2, but it should be possible to plug in other formats.

Comment on lines +99 to +100
hostnames:
- "*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd recommend leaving this out as it's implied.


This GEP proposes the following API changes:

* Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding and new `HTTPRegexModifier` field
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding and new `HTTPRegexModifier` field
* Update [httproute_types.go](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1beta1/httproute_types.go) by adding a new `HTTPRegexModifier` field

Comment on lines +12 to +13
Close the regex-based path rewrites feature gap for Gateway API, i.e.:
* Rewrite the path of a request based on a regular expression, regardless of initial match type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly our docs generator requires a new line before lists like this:

Suggested change
Close the regex-based path rewrites feature gap for Gateway API, i.e.:
* Rewrite the path of a request based on a regular expression, regardless of initial match type
Close the regex-based path rewrites feature gap for Gateway API, i.e.:
* Rewrite the path of a request based on a regular expression, regardless of initial match type


The relationship between new fields shluld stay invartiant across different underlying implementaions and dataplanes. The syntax, however, may vary depending on the implementation.

* `pathPattern` The regular expression used to find portions of a string (hereafter called the “subject string”) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string.
Copy link
Member

@rikatz rikatz Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `pathPattern` The regular expression used to find portions of a string (hereafter called the subject string) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string.
* `pathPattern` The regular expression used to find portions of a string (hereafter called the `subject string`) that should be replaced. When a new string is produced during the substitution operation, the new string is initially the same as the subject string, but then all matches in the subject string are replaced by the substitution string. If replacing all matches isn’t desired, regular expression anchors can be used to ensure a single match, so as to replace just one occurrence of a pattern. Capture groups can be used in the pattern to extract portions of the subject string, and then referenced in the substitution string.

relationships:
seeAlso:
- https://gateway-api.sigs.k8s.io/geps/gep-726/#future-extension
references:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add the references of nginx and haproxy here so we can keep it more agnostic? thanks! :D

@rikatz
Copy link
Member

rikatz commented Dec 22, 2025

Hi @muxanasov and thanks for the proposal!

I agree this is a very important feature to get people moving to Gateway API, I would just like to put my "ingress-nginx former maintainer" hat a bit: having regexes as part of the API can be very very complex (and somehow dangerous):

  • the Regex parser used by Envoy (re2) is different from NGINX (PCRE) and can even be different from other implementations that may be pure Go or pure Rust, or even on different technologies. So it would be a bit "hard" to define conformance, if each implementation behaves on a different way.
  • Because the subset of regex characters that can be used on an API field is big, and because eventually these characters may end up on a proxy configuration file (eg.: NGINX or HAProxy), we need to be really careful with what characters we would allow. We won't be able to do any validation on the API side, because we will be able to only limit the characters for non-characters control but not really define if that is a valid regex. So it is a wide open arbitrary API field
  • On some cases, IIRC a regex can be used for internal redirects, that may lead to users pointing to internal non-exposed endpoints. This is a bit risky

That said, I think we do need some feature like this, but if possible I would like to try to scope it to:

  • Can we define a minimum regex set that is acceptable by all the parsers, with a minimum set of characters? (eg.: can we define what is the acceptable set of characters that we could validate?)
  • Should this be "Implementation Specific", given each implementation may have its own way of parsing a regex?
  • Is there any "user story" of regexes that could actually be covered by a lack of some other API that would be more strict?

Thanks again for the proposal!

Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall in favor of the direction but I think the API itself could use a few tweaks

// Support: Extended
//
// +optional
RegexModifier *HTTPRegexModifier `json:"regexModifier,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nitpicking on field names here.

This seems a bit odd. It says its about path OR host, but it only has path. Maybe the intent was to add hostPattern and hostSubstitute in the future, but that is somewhat awkward....

Why not adding this under HTTPPathModifier?

So

path:
  type: Regex
  regex:
    match: blah
    substitution: blah

this seems more consistent with the existing API

// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=1024
PathPattern *string `json:"pathPattern,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required for the GEP but we really really need some examples here for users

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And details on the matching semantics. Is it a full string match or substring? Should it match the leading /?

filters:
- type: URLRewrite
urlRewrite:
regexModifier:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is a good idea but wanted to mention it.

Given regex is implementation specific, and even more so with capture groups, do we event want to bother tying this to regex?

For example, an implementation could support:

pattern: /region/{region}/bucket/{storage}/{object}.pdf
substitution: /{region}/bucket-{storage}/{object}.pdf

which is not regex but fulfills the same purpose (not saying we make that syntax part of the spec, just that if we remove "regex" to "pattern" we could enable it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/gep PRs related to Gateway Enhancement Proposal(GEP) ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants