Skip to content

Commit 21cd966

Browse files
authored
Remove global-rate-limit feature (#11851)
1 parent 5243b9b commit 21cd966

File tree

25 files changed

+28
-1326
lines changed

25 files changed

+28
-1326
lines changed

charts/ingress-nginx/tests/controller-configmap_test.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@ tests:
1616
- it: should create a ConfigMap with templated values if `controller.config` contains templates
1717
set:
1818
controller.config:
19-
global-rate-limit-memcached-host: "memcached.{{ .Release.Namespace }}.svc.kubernetes.local"
20-
global-rate-limit-memcached-port: 11211
2119
use-gzip: true
2220
asserts:
23-
- equal:
24-
path: data.global-rate-limit-memcached-host
25-
value: memcached.NAMESPACE.svc.kubernetes.local
26-
- equal:
27-
path: data.global-rate-limit-memcached-port
28-
value: "11211"
2921
- equal:
3022
path: data.use-gzip
3123
value: "true"

docs/e2e-tests.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Do not try to edit it manually.
77

88

99
### [[Admission] admission controller](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/admission/admission.go#L39)
10-
- [reject ingress with global-rate-limit annotations when memcached is not configured](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/admission/admission.go#L47)
1110
- [should not allow overlaps of host and paths without canary annotations](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/admission/admission.go#L74)
1211
- [should allow overlaps of host and paths with canary annotation](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/admission/admission.go#L91)
1312
- [should block ingress with invalid path](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/admission/admission.go#L112)
@@ -173,8 +172,6 @@ Do not try to edit it manually.
173172
### [from-to-www-redirect](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/fromtowwwredirect.go#L31)
174173
- [should redirect from www HTTP to HTTP](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/fromtowwwredirect.go#L38)
175174
- [should redirect from www HTTPS to HTTPS](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/fromtowwwredirect.go#L64)
176-
### [annotation-global-rate-limit](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/globalratelimit.go#L30)
177-
- [generates correct configuration](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/globalratelimit.go#L38)
178175
### [backend-protocol - GRPC](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/grpc.go#L45)
179176
- [should use grpc_pass in the configuration file](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/grpc.go#L48)
180177
- [should return OK for service with backend protocol GRPC](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/annotations/grpc.go#L71)
@@ -420,8 +417,6 @@ Do not try to edit it manually.
420417
### [global-options](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/global_options.go#L28)
421418
- [should have worker_rlimit_nofile option](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/global_options.go#L31)
422419
- [should have worker_rlimit_nofile option and be independent on amount of worker processes](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/global_options.go#L37)
423-
### [settings-global-rate-limit](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/globalratelimit.go#L30)
424-
- [generates correct NGINX configuration](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/globalratelimit.go#L38)
425420
### [GRPC](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/grpc.go#L39)
426421
- [should set the correct GRPC Buffer Size](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/grpc.go#L42)
427422
### [gzip](https://github.com/kubernetes/ingress-nginx/tree/main//test/e2e/settings/gzip.go#L30)

docs/user-guide/nginx-configuration/annotations-risk.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
| ExternalAuth | auth-url | High | location |
5656
| FastCGI | fastcgi-index | Medium | location |
5757
| FastCGI | fastcgi-params-configmap | Medium | location |
58-
| GlobalRateLimit | global-rate-limit | Low | ingress |
59-
| GlobalRateLimit | global-rate-limit-ignored-cidrs | Medium | ingress |
60-
| GlobalRateLimit | global-rate-limit-key | High | ingress |
61-
| GlobalRateLimit | global-rate-limit-window | Low | ingress |
6258
| HTTP2PushPreload | http2-push-preload | Low | location |
6359
| LoadBalancing | load-balance | Low | location |
6460
| Logs | enable-access-log | Low | location |

docs/user-guide/nginx-configuration/annotations.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ You can add these Kubernetes annotations to specific Ingress objects to customiz
6464
|[nginx.ingress.kubernetes.io/http2-push-preload](#http2-push-preload)|"true" or "false"|
6565
|[nginx.ingress.kubernetes.io/limit-connections](#rate-limiting)|number|
6666
|[nginx.ingress.kubernetes.io/limit-rps](#rate-limiting)|number|
67-
|[nginx.ingress.kubernetes.io/global-rate-limit](#global-rate-limiting)|number|
68-
|[nginx.ingress.kubernetes.io/global-rate-limit-window](#global-rate-limiting)|duration|
69-
|[nginx.ingress.kubernetes.io/global-rate-limit-key](#global-rate-limiting)|string|
70-
|[nginx.ingress.kubernetes.io/global-rate-limit-ignored-cidrs](#global-rate-limiting)|string|
7167
|[nginx.ingress.kubernetes.io/permanent-redirect](#permanent-redirect)|string|
7268
|[nginx.ingress.kubernetes.io/permanent-redirect-code](#permanent-redirect-code)|number|
7369
|[nginx.ingress.kubernetes.io/temporal-redirect](#temporal-redirect)|string|
@@ -560,46 +556,6 @@ To configure settings globally for all Ingress rules, the `limit-rate-after` and
560556

561557
The client IP address will be set based on the use of [PROXY protocol](./configmap.md#use-proxy-protocol) or from the `X-Forwarded-For` header value when [use-forwarded-headers](./configmap.md#use-forwarded-headers) is enabled.
562558

563-
### Global Rate Limiting
564-
565-
**Note:** Be careful when configuring both (Local) Rate Limiting and Global Rate Limiting at the same time.
566-
They are two completely different rate limiting implementations. Whichever limit exceeds first will reject the
567-
requests. It might be a good idea to configure both of them to ease load on Global Rate Limiting backend
568-
in cases of spike in traffic.
569-
570-
The stock NGINX rate limiting does not share its counters among different NGINX instances.
571-
Given that most ingress-nginx deployments are elastic and number of replicas can change any day
572-
it is impossible to configure a proper rate limit using stock NGINX functionalities.
573-
Global Rate Limiting overcome this by using [lua-resty-global-throttle](https://github.com/ElvinEfendi/lua-resty-global-throttle). `lua-resty-global-throttle` shares its counters via a central store such as `memcached`.
574-
The obvious shortcoming of this is users have to deploy and operate a `memcached` instance
575-
in order to benefit from this functionality. Configure the `memcached`
576-
using [these configmap settings](./configmap.md#global-rate-limit).
577-
578-
**Here are a few remarks for ingress-nginx integration of `lua-resty-global-throttle`:**
579-
580-
1. We minimize `memcached` access by caching exceeding limit decisions. The expiry of
581-
cache entry is the desired delay `lua-resty-global-throttle` calculates for us.
582-
The Lua Shared Dictionary used for that is `global_throttle_cache`. Currently its size defaults to 10M.
583-
Customize it as per your needs using [lua-shared-dicts](./configmap.md#lua-shared-dicts).
584-
When we fail to cache the exceeding limit decision then we log an NGINX error. You can monitor
585-
for that error to decide if you need to bump the cache size. Without cache the cost of processing a
586-
request is two memcached commands: `GET`, and `INCR`. With the cache it is only `INCR`.
587-
1. Log NGINX variable `$global_rate_limit_exceeding`'s value to have some visibility into
588-
what portion of requests are rejected (value `y`), whether they are rejected using cached decision (value `c`),
589-
or if they are not rejected (default value `n`). You can use [log-format-upstream](./configmap.md#log-format-upstream)
590-
to include that in access logs.
591-
1. In case of an error it will log the error message and **fail open**.
592-
1. The annotations below creates Global Rate Limiting instance per ingress.
593-
That means if there are multiple paths configured under the same ingress,
594-
the Global Rate Limiting will count requests to all the paths under the same counter.
595-
Extract a path out into its own ingress if you need to isolate a certain path.
596-
597-
598-
* `nginx.ingress.kubernetes.io/global-rate-limit`: Configures maximum allowed number of requests per window. Required.
599-
* `nginx.ingress.kubernetes.io/global-rate-limit-window`: Configures a time window (i.e `1m`) that the limit is applied. Required.
600-
* `nginx.ingress.kubernetes.io/global-rate-limit-key`: Configures a key for counting the samples. Defaults to `$remote_addr`. You can also combine multiple NGINX variables here, like `${remote_addr}-${http_x_api_client}` which would mean the limit will be applied to requests coming from the same API client (indicated by `X-API-Client` HTTP request header) with the same source IP address.
601-
* `nginx.ingress.kubernetes.io/global-rate-limit-ignored-cidrs`: comma separated list of IPs and CIDRs to match client IP against. When there's a match request is not considered for rate limiting.
602-
603559
### Permanent Redirect
604560

605561
This annotation allows to return a permanent redirect (Return Code 301) instead of sending data to the upstream. For example `nginx.ingress.kubernetes.io/permanent-redirect: https://www.google.com` would redirect everything to Google.

docs/user-guide/nginx-configuration/configmap.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ The following table shows a configuration option's name, type, and the default v
218218
| [block-referers](#block-referers) | []string | "" | |
219219
| [proxy-ssl-location-only](#proxy-ssl-location-only) | bool | "false" | |
220220
| [default-type](#default-type) | string | "text/html" | |
221-
| [global-rate-limit-memcached-host](#global-rate-limit) | string | "" | |
222-
| [global-rate-limit-memcached-port](#global-rate-limit) | int | 11211 | |
223-
| [global-rate-limit-memcached-connect-timeout](#global-rate-limit) | int | 50 | |
224-
| [global-rate-limit-memcached-max-idle-timeout](#global-rate-limit) | int | 10000 | |
225-
| [global-rate-limit-memcached-pool-size](#global-rate-limit) | int | 50 | |
226-
| [global-rate-limit-status-code](#global-rate-limit) | int | 429 | |
227221
| [service-upstream](#service-upstream) | bool | "false" | |
228222
| [ssl-reject-handshake](#ssl-reject-handshake) | bool | "false" | |
229223
| [debug-connections](#debug-connections) | []string | "127.0.0.1,1.1.1.1/24" | |
@@ -1349,22 +1343,6 @@ _**default:**_ text/html
13491343
_References:_
13501344
[https://nginx.org/en/docs/http/ngx_http_core_module.html#default_type](https://nginx.org/en/docs/http/ngx_http_core_module.html#default_type)
13511345

1352-
## global-rate-limit
1353-
1354-
* `global-rate-limit-status-code`: configure HTTP status code to return when rejecting requests. Defaults to 429.
1355-
1356-
Configure `memcached` client for [Global Rate Limiting](https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md#global-rate-limiting).
1357-
1358-
* `global-rate-limit-memcached-host`: IP/FQDN of memcached server to use. Required to enable Global Rate Limiting.
1359-
* `global-rate-limit-memcached-port`: port of memcached server to use. Defaults default memcached port of `11211`.
1360-
* `global-rate-limit-memcached-connect-timeout`: configure timeout for connect, send and receive operations. Unit is millisecond. Defaults to 50ms.
1361-
* `global-rate-limit-memcached-max-idle-timeout`: configure timeout for cleaning idle connections. Unit is millisecond. Defaults to 50ms.
1362-
* `global-rate-limit-memcached-pool-size`: configure number of max connections to keep alive. Make sure your `memcached` server can handle
1363-
`global-rate-limit-memcached-pool-size * worker-processes * <number of ingress-nginx replicas>` simultaneous connections.
1364-
1365-
These settings get used by [lua-resty-global-throttle](https://github.com/ElvinEfendi/lua-resty-global-throttle)
1366-
that ingress-nginx includes. Refer to the link to learn more about `lua-resty-global-throttle`.
1367-
13681346
## service-upstream
13691347

13701348
Set if the service's Cluster IP and port should be used instead of a list of all endpoints. This can be overwritten by an annotation on an Ingress rule.

images/nginx-1.25/rootfs/build.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ export LUA_RESTY_REDIS_VERSION=8641b9f1b6f75cca50c90cf8ca5c502ad8950aa8
9898
# Check for recent changes: https://github.com/api7/lua-resty-ipmatcher/compare/v0.6.1...master
9999
export LUA_RESTY_IPMATCHER_VERSION=3e93c53eb8c9884efe939ef070486a0e507cc5be
100100

101-
# Check for recent changes: https://github.com/ElvinEfendi/lua-resty-global-throttle/compare/v0.2.0...main
102-
export LUA_RESTY_GLOBAL_THROTTLE_VERSION=v0.2.0
103-
104101
# Check for recent changes: https://github.com/microsoft/mimalloc/compare/v2.1.7...master
105102
export MIMALOC_VERSION=v2.1.7
106103

@@ -276,9 +273,6 @@ get_src c15aed1a01c88a3a6387d9af67a957dff670357f5fdb4ee182beb44635eef3f1 \
276273
get_src efb767487ea3f6031577b9b224467ddbda2ad51a41c5867a47582d4ad85d609e \
277274
"https://github.com/api7/lua-resty-ipmatcher/archive/$LUA_RESTY_IPMATCHER_VERSION.tar.gz" "lua-resty-ipmatcher"
278275

279-
get_src 0fb790e394510e73fdba1492e576aaec0b8ee9ef08e3e821ce253a07719cf7ea \
280-
"https://github.com/ElvinEfendi/lua-resty-global-throttle/archive/$LUA_RESTY_GLOBAL_THROTTLE_VERSION.tar.gz" "lua-resty-global-throttle"
281-
282276
get_src d74f86ada2329016068bc5a243268f1f555edd620b6a7d6ce89295e7d6cf18da \
283277
"https://github.com/microsoft/mimalloc/archive/${MIMALOC_VERSION}.tar.gz" "mimalloc"
284278

@@ -591,9 +585,6 @@ make install
591585
cd "$BUILD_PATH/lua-resty-ipmatcher"
592586
INST_LUADIR=/usr/local/lib/lua make install
593587

594-
cd "$BUILD_PATH/lua-resty-global-throttle"
595-
make install
596-
597588
cd "$BUILD_PATH/mimalloc"
598589
mkdir -p out/release
599590
cd out/release

0 commit comments

Comments
 (0)