-
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
Generalize Rewrite Block Creation and Deprecate AddBaseUrl (not backwards compatible) #3174
Conversation
/lgtm |
The way I understand this is it enforces using regexp group references explicitly in So given an ingress with regexp path enabled and rewrite-target is "/new/$1". And there are two paths
will be generated accordingly. This means foo/baz/anything will be rewritten to I don't know what's the best solution here, maybe we should stop trying to make the controller smart about generating the correct rewrite syntax and let the user take are of that. Because to me it seems like impossible to find a common ground. Therefore it would make sense to let user do whatever they want. That would also simplify controller logic. Nginx rewrite directive has two required arguments:
So given that whenever rewrite target is used we enforce regepx path matching, I'd delete all the existing logic where we try to come up with correct arguments to For example the simplest case when you want to rewrite
this is obviously not backward compatible, but I really dislike the complexity around the current solution, and this solution will make it simpler to reason about. |
@ElvinEfendi I completely agree. Giving the user control of whether or not to append parameters to rewritten paths in all cases makes way more sense. Defaulting to enforcing this policy, especially now that regex is enabled, seems counterintuitive. |
@zrdaley please squash the commits |
@@ -139,14 +138,13 @@ proxy_pass http://upstream-name; | |||
false, | |||
false, | |||
false, | |||
true}, | |||
false}, |
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.
Why is this false
, when there's rewrite enforceRegex is always true
, no?
/hold @zrdaley please update PR title and description accordingly now that we pivoted. -- This change is not backward compatible and it is going to break every single rewrite configuration. The logic at https://github.com/kubernetes/ingress-nginx/pull/3174/files#diff-652deabba49a2a87d4c5a79700dfa1e3R331 does not make much sense with regexp path support and specially after this PR. With this PR users will have to have something like This test https://github.com/kubernetes/ingress-nginx/pull/3174/files#diff-780db26d3e78669defcf119bfb8a9b64R43 now is not so useful. We should make sure it tests that path suffix ( |
@zrdaley friendly ping |
@ElvinEfendi I agree with the deprecation of Also, is there an official way to notify users of backwards compatibility issues or will the change of name above be sufficient? I am just going to remove this test https://github.com/kubernetes/ingress-nginx/pull/3174/files#diff-780db26d3e78669defcf119bfb8a9b64R43. This test https://github.com/kubernetes/ingress-nginx/pull/3174/files?utf8=%E2%9C%93&diff=unified#diff-780db26d3e78669defcf119bfb8a9b64R257 cover's suffix appending for both the index and all other path cases since there is no longer a special case for the index path. |
47f6cb1
to
4a6a6f5
Compare
4a6a6f5
to
9fa7964
Compare
@dshakey could you share your code change. That would be much appreciated. |
How can I configure
Legend:
Example URI:s that should match the above pattern:
|
@Gilgames000 Thanks. I've updated the SO post. |
I'm using the latest
When I go to I'm expecting success response when I go to |
@buianhthang try this: |
Not happy about having my app break and needing to sift through these comments, reaching the bottom and not finding a reasonable workaround. For clarity, what is now the canonical solution? This is a bit of a head scratcher. |
@avik-so Have you found a reasonable solution? Facing the same - dead in the water |
@scniro this is a change introduced more than a year ago. The example https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target is up to date. |
@scniro Only options are to use the new syntax or use version 0.21.0 |
One day I'll write a blog post about migrating 80+ Kubernetes clusters:
via a mutating admission webhook that creates almost identical copy of an Ingress resource, but with a different That was quite a journey. :) |
For folks ending up here and wondering what they could do, we solved the backward incompatible by having the anntoation be the following;
This made sure that the |
Are there any solutions at all that will work both before and after this change? We don't have the option of upgrading and having requests fail until all the teams redeploy all their apps with a fixed ingress. Most of our rewrites are simple:
I've tried different combinations of the new syntax, like:
And:
But the rewrite rule ends up weird in the old version of the nginx.conf:
|
This is a bad breaking change and not backward compatible. For a frontend web app with multiple backend services, the configuration of the ingress became very weird after the upgrades. Is it possible to add a switch for a user to decide if turn on the change or not? |
As far as we have been able to figure out, this change requires downtime to redeploy. |
It solved my problem! Thank You! |
how do you solve this case #3770 ? |
I have IC version 0.20.0 and the following configuration works, but NOT with 0.30.0:
I replaced the
can you please help? |
It has been deprecated a long time ago: kubernetes/ingress-nginx#3174
* Configuration: Prepend `nginx` to annotations. * Configuration: Remove `nginx.ingress.kubernetes.io/add-base-url`. Deprecated: kubernetes/ingress-nginx#3174 * Configuration: Remove `nginx.ingress.kubernetes.io/session-cookie-hash`. Deprecated: kubernetes/ingress-nginx#3743 * Configuration: Bump `last_review_date`. * Multiple Ingress NGINX Controllers: Remove deprecated `controller.ingressClass`. * Multiple Ingress NGINX Controllers: Remove wildcard from `controller.service.subdomain`. * Multiple Ingress NGINX Controllers: Migrate `configmap` to `controller.config`. * Multiple Ingress NGINX Controllers: Bump `last_review_date`. * Service Type LoadBalancer: Make `service.beta.kubernetes.io/aws-load-balancer-internal` a boolean. * Service Type LoadBalancer: Make `service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval` a string. * Service Type LoadBalancer: Move `Other AWS ELB configuration options`. * Service Type LoadBalancer: Document Martian Packets when using internal AWS Network Load Balancers. * Service Type LoadBalancer: Document Health Checks failing when using PROXY protocol and `externalTrafficPolicy: Local`. * Service Type LoadBalancer: Document Security Group configuration on internal AWS Network Load Balancers. * Service Type LoadBalancer: Bump `last_review_date`.
What this PR does / why we need it:
When the
rewrite-target
annotation is used and the written path uses regex and does not end in/
(ex.foo/bar/.+
), rewrite does not work as expected. This provides a regex check inBuildProxyPass
and uses a custom rewrite block if theuse-regex
annotation is true for a location.UPDATE
In addition to the above, this PR deprecates the
AddBaseUrl
annotation.Problem
An ingress is created with
use-regex="true"
andrewrite-target="/new"
and the path/foo/bar/.+
.This results in the following rewrite blocks for that location:
Therefore a request to
/foo/bar/bar
will go to/new
instead of/new/bar
as a user may expect.Solution
Check if a use-regex is true for a location when building the proxy pass.
An ingress is created with
use-regex="true"
andrewrite-target="/new/$1"
and the path/foo/bar/(.+)
.This results in the following rewrite blocks for that location:
Now a request to
/foo/bar/bar
will go to/new/bar
.