HttpRoute should be able to match path prefix with case-insensitive option
What would you like to be added:
Support for case-insensitive path prefix matching, e.g. with caseSensitive: false (naming not important to me, that's how it's called in xDS if you're using Envoy).
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: proxy-from-k8s-to-httpbin
spec:
rules:
- backendRefs:
- ...
matches:
- path:
type: PathPrefix
value: /httpbin
caseSensitive: false
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: /
Why this is needed:
HttpRoute currently requires regular expressions to achieve case-insensitive path prefix matching.
- Existing code may expect URLs to be case-insensitive, since file systems can be case-insensitive. Windows Servers are a good example. Also, case-insensitivity helps users who might enter a URL manually in their address bar.
- We would also like to use
replacePrefixMatchon a URLRewrite. This is explicitly disallowed for regular expressions, so we really need the case-insensitive support on prefix matches, specifically. - Regular expressions are still a less optimal solution regardless:
- The specific Gateway implementation may not guarantee reasonable ordering, and there is no flag to denote the priority of a regex match. We have to rely on a specific implementation like Envoy Gateway ordering the regular expression routes sensibly, which is not guaranteed by the Gateway API itself. If they are mis-ordered, a less specific path match could apply first. This is a problem if a more root path has an authentication requirement, but a nested, more specific path is intentionally public (like is common if you have a
/prefix/authenticatepath that accepts credentials to authenticate in the first place). - Regular expressions could be less performant.
- The specific Gateway implementation may not guarantee reasonable ordering, and there is no flag to denote the priority of a regex match. We have to rely on a specific implementation like Envoy Gateway ordering the regular expression routes sensibly, which is not guaranteed by the Gateway API itself. If they are mis-ordered, a less specific path match could apply first. This is a problem if a more root path has an authentication requirement, but a nested, more specific path is intentionally public (like is common if you have a
- Feature parity with other API Gateway technologies (some required fields have be removed for brevity of examples):
- Istio VirtualService, see
ignoreUriCase:apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: proxy-from-k8s-to-httpbin spec: http: - match: - uri: prefix: /httpbin ignoreUriCase: true rewrite: uri: / - Kong Gateway which uses Kubernetes Ingress API (doesn't have case-insensitive, but Kong has explicit regex priority for confidence the more nested, specific route is applied):
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: proxy-from-k8s-to-httpbin annotations: kubernetes.io/ingress.class: kong konghq.com/strip-path: \"true\" konghq.com/regex-priority: \"1\" spec: rules: - http: paths: - path: /~/(?i)httpbin pathType: ImplementationSpecific --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: proxy-from-k8s-to-httpbin-get annotations: kubernetes.io/ingress.class: kong konghq.com/strip-path: \"true\" konghq.com/regex-priority: \"2\" spec: rules: - http: paths: - path: /~/(?i)httpbin/get pathType: ImplementationSpecific
- Istio VirtualService, see
From documentation:
ReplacePrefixMatch is only compatible with a
PathPrefixHTTPRouteMatch.
Thanks for filing this @gorban! If you have time to work on this in the next 2-3 months, do you mind proposing it in our v1.2 release scoping discussion?
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle stale - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
I do not want to discourage this proposal, but only to point out that the generic syntax for the HTTP path component determines it to be case-sensitive (RFC 3986).
I understand vendors may have opted to be less strict about this (either aiming for improved user experience or due to historical reasons) and I reckon the reasoning on trying to normalise the practice into the API (instead of fighting against it), regardless of what the spec says.
Perhaps my only piece of advice here then would be to ensure this concession relatively the RFC is somehow mentioned in the docs if this proposal ends up being accepted?
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue as fresh with
/remove-lifecycle rotten - Close this issue with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
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.