-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add location-modifier annotation to allow simple reg-ex locations #1415
Add location-modifier annotation to allow simple reg-ex locations #1415
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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/test-infra repository. I understand the commands that are listed here. |
17da93d
to
8a56f42
Compare
} | ||
|
||
newLoc := buildLocation(loc) | ||
if tc.Location != newLoc { | ||
t.Errorf("%s: expected '%v' but returned %v", k, tc.Location, newLoc) | ||
t.Errorf("%s: expected '%v' but returned '%v'", k, tc.Location, newLoc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quotes around the second argument were missing.
8a56f42
to
e406dce
Compare
appRoot = "ingress.kubernetes.io/app-root" | ||
rewriteTo = "ingress.kubernetes.io/rewrite-target" | ||
locationModifier = "ingress.kubernetes.io/location-modifier" | ||
defaultRewriteLocationModifier = "~*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 'location-modifier' too nginx specific to be in core?
CLA has been signed.... |
Coverage increased (+0.2%) to 43.719% when pulling e406dce22905a9871f84f243e45f908bebe9b023 on gesundheitscloud:pq/location_modifier_annotation into e43641f on kubernetes:master. |
Coverage increased (+0.1%) to 43.707% when pulling e406dce22905a9871f84f243e45f908bebe9b023 on gesundheitscloud:pq/location_modifier_annotation into e43641f on kubernetes:master. |
Coverage increased (+0.1%) to 43.707% when pulling e406dce22905a9871f84f243e45f908bebe9b023 on gesundheitscloud:pq/location_modifier_annotation into e43641f on kubernetes:master. |
bd04459
to
d282ddd
Compare
Coverage increased (+0.2%) to 43.886% when pulling d282ddda0a77dc74ebcca3fe8f643d461b2f780b on gesundheitscloud:pq/location_modifier_annotation into 6e24dc6 on kubernetes:master. |
Coverage increased (+0.1%) to 43.874% when pulling d282ddda0a77dc74ebcca3fe8f643d461b2f780b on gesundheitscloud:pq/location_modifier_annotation into 6e24dc6 on kubernetes:master. |
d282ddd
to
7ff049f
Compare
Is there a docker image containing this modification available somewhere? |
@aledbf @nicksardo could you guys take a quick look at this please? it's a minor change that fixes a major issue. Thanks. |
Actually, I think the patch will completely fix (not partially as I earlier stated) the issues described in #1260 |
@paalkr I'm afraid the docker image I'm using is in a private repo... should be easily build from the branch though |
7ff049f
to
a609b86
Compare
rebased... |
Coverage increased (+0.2%) to 33.707% when pulling a609b86607a7ba99e429fdf7c934da2e6563fa65 on gesundheitscloud:pq/location_modifier_annotation into a18daab on kubernetes:master. |
@pussinboots thank you. I will review this weekend and merge (if I don't find anything else during testing) |
In nginx a modifier can be passed which decides how locations will be parsed, i.e. regex or no regex. This change allows a location modifier to be passed as an annotatione e.g. ingress.kubernetes.io/location-modifier: "~" If no location-modifier is passed but 'rewrite-target' is provided, then a default of "*~" is assumed.
e9e5449
to
b2fbd09
Compare
@pussinboots please check this example
Executing the next example should return
|
@pussinboots any overlap between "normal" paths and regular expression ends routing traffic to the route with regular expressions. |
First of all thanks for finding this out. It is also not covered yet in the e2e test case. I found a good short explanation here
|
@pussinboots this is the reason why I never implemented this feature.
or
those approaches work but imply we need to check all the paths in the model before creating the nginx.conf file. |
That is what i also discover now. :-) To simplify things here i would suppose to make it possible at least for now to define If you setup ingress paths for nginx you should maybe aware of the different location I will extend the regex test with your test cases. |
Hi what you think about instead of dealing with checking the paths It could be supported by a tool that you can run and check if the url |
@pussinboots I thin this approach can help to simplify the regex support https://forum.nginx.org/read.php?2,279504,279512#msg-279512
(not sure it works) |
That is a good idea. How would the ingress configuration look like?
Or does ingress support nested paths? |
To everyone following this thread: I think I found a way to fix the lack of regex support but before opening a PR I need help with concrete examples of Ingresses to use as a test case. Please attach comments with examples of ingresses with at least two or more paths where at least one is a regex. Edit: this will not require additional annotations |
This is (an excerpt of) my actual real-life use-case. The paths to grpc services are namespaced with dots instead of slashes, which is unfortunate if I want to route them with an ingress. rules:
- host: api.listenfield.com
http:
paths:
- path: /listenfield\.auth\..*/
backend:
serviceName: auth-service
servicePort: grpc
- path: /listenfield\.repo\..*/
backend:
serviceName: farm-repo-api-service
servicePort: grpc
- path: /hj/repo/
backend:
serviceName: farm-repo-api-json-service
servicePort: http |
This is a must-have use-case for us as all our REST services are organized in this way: rules:
- host: api.company.com
http:
paths:
- path: ^v1/users.*$
backend:
serviceName: user-service
servicePort: http
- path: ^v1/users/.*/products$
backend:
serviceName: user-products-service
servicePort: http
|
We're looking to migrate an existing API into nginx ingress and this is a must have in order for it to work
|
@aledbf Any chance to see this PR merged ? |
@barryib no in the current state. I hope I can work on this in the next release cycle |
hi guys, acorrding #1360 (comment) maybe this works?
|
Closing. Implemented in #3145 |
Please help us to test this feature. Please check doc https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/ingress-path-matching.md |
Pass location modifier in annotation
Ingress paths can now have regex:
In nginx a modifier can be passed which decides how locations will be parsed, i.e. regex or no regex.
This change allows a location modifier to be passed as an annotation.
If no location-modifier is passed but 'rewrite-target' is provided, then a default of "*~" is assumed.