-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Scale rate-limit with ingress-pods #4894
Comments
Hi @dbaumgarten thanks for reporting! Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this 🙂 Cheers! |
Given the explanation of the problem is the expectation that:
Something that I am not entirely sure of, can a watcher be placed on the deployment itself so that there is an event that can be responded to? It is that part I am curious about. |
Correct, the Ingress Controller would reconfigure the config for each Ingress that uses the feature whenever it scales. VirtualServers could also bei extended to support this. My idea would be to use the endpointslice of the controller's service. The controller is already watching endpointslices. And the active endpoints of the service are what actually counts. The replica count of the deployment doesn't really matter. What counts is how many replicas are actually receiving traffic. |
Hey @brianehlert , I have prepared a draft for this proposal: https://github.com/dbaumgarten/kubernetes-ingress/tree/feature/ratelimit-scaling The required changes were surprisingly small: dbaumgarten@4c728fa What do you think about it? |
Hi @brianehlert |
Hi @dbaumgarten We currently enable rate limiting for VS and VSR through our Policy resource, so it would be best for this feature to be set there. Thanks! |
I have prepared a PR including support für VirtualServers. |
Hi @dbaumgarten, we will hopefully be reviewing this PR before end of this month, appreciate your patience on this! |
@vepatel The month is almost over. Any news? |
Great work on this PR! I've tested this for both VirtualServers and Ingresses, and the maths scales for changes in NIC pod configurations. However, there are a couple of points I'd like to discuss:
Thanks for your efforts on this! You are welcome to join our community call on Tuesday to discuss this further. Meeting info is the README. |
Hi, However if the intention of the rate-limit is to block out DOS-Attacks then the ratelimit is usually high enough to allow legitimate traffic even if load is not distributed perfectly. And especially in case of DOS-Attacks it is important that you can scale to take the load without breaking your ratelimiting. NGINX+ zone-sync feature is indeed the optimal solution to the problem as it guarantees proper ratelimits across any number of pods. If have evaluted it in the past (using snippets) and it works fine. Unfortunately NGINX+ comes at quite the price. So my suggestion would be:
I will try to join the Community meeting on 2024-05-20, so we can discuss this further if required. |
As agreed on on the community meeting: If have clarified the documentation about this feature. |
Is your feature request related to a problem? Please describe.
This is a continuation of #4603 .
Now that #4660 is merged, there is support for basic rate-limiting via annotations.
The problem that remains is that the rate-limit is applied per-pod.
If there are for example three ingress-pods, it will effectively triple the amount of allowed request.
In case the number of ingress-pods is static, users could simply manually compensate for this.
However when autoscaling for the ingress-pods is enabled, this is not possible anymore.
Just yesterday we (again) had the case that we were hit by a DoS-Attack. Nginx scaled up to handle the traffic and started to block requests, but because of the scaling the blocking was not as effective as we hoped.
Describe the solution you'd like
I would suppose to add an additional annotation that enables the following behaviour:
The rate-limit provided by the user is divided by the amount of currently active ingress pods.
This way the total amount of allowed request always stays the same.
Yes, this will only work when incoming traffic is distributed evenly to all active nginx-pods. This will not always be the case (there could be session-presistence in the LB in front of nginx), but I suspect that this is the case most of the time.
Simple things should be simple and complicated things should be possible:
Users with a simple network-setting could use this annotation and everyone who needs more control could use nginx+ (see alternatives below).
If you are ok with this, I would implement this and open a PR.
Describe alternatives you've considered
a) Implement a kubernetes-controller that monitors the amount of running nginx-pods and automatically adjusts the ingress-objects.
-> Would surely work, but that is one more moving part that could break. And as the nginx-controller already has all the required information it feels weird to introduce an additional component.
b) Use nginx+ with zone sync
-> Would probably work, but as nginx+ is quite expensive it's not really a solution for everyone. However this might be the only viable option for users with non-trivial networking setups.
The text was updated successfully, but these errors were encountered: