Possible to set "whitelisted ips" in ratelimiting
Title: Set ratelimiting to all cidrs with exceptions
Description:
I have usecase that I should add ratelimiting to all addresses (0.0.0.0/0) EXCEPT few "whitelisted ips". As I see it, it is quite common use case that people want to set rate limits to everything except few internal api ips (whitelist services that should work always, no matter what).
Relevant Links: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-ratelimit-action
currently envoy does not support exceptions to the remote_address matcher. But it could have "not logic"?
I think a "composite" filter could help here. You could wrap the enforcement in a conditional filter that limits the application of the enforcement filter.
@kyessenov Do you have any idea why this does not work, this is built following the reference here
The idea is to set a lower limit for certain CIDR blocks and for rest restrict to higher limit.
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: api--rate-limit-all
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: api--http-route
rateLimit:
type: Global
global:
rules:
- limit:
requests: 100
unit: Second
- limit:
requests: 500
unit: Minute
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: api--limit-whitelist
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: api--http-route
rateLimit:
type: Global
global:
rules:
- clientSelectors:
- sourceCIDR:
value: x.y.z.r/30
type: Distinct
- sourceCIDR:
value: x.y.x.r/32
- sourceCIDR:
value: x.y.x.r/32
- sourceCIDR:
value: x.y.x.r/32
- sourceCIDR:
value: x.y.x.r/31
type: Distinct
limit:
requests: 10000
unit: Minute
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: api--http-route
spec:
parentRefs:
- name: external-gateway
hostnames:
- example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
filters:
- type: ExtensionRef
extensionRef:
group: gateway.envoyproxy.io
kind: RateLimitFilter
name: api--limit-whitelist
backendRefs:
- name: api--service
port: 3000
- matches:
- path:
type: PathPrefix
value: /
filters:
- type: ExtensionRef
extensionRef:
group: gateway.envoyproxy.io
kind: RateLimitFilter
name: api--rate-limit-all
backendRefs:
- name: api--service
port: 3000
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
cidr match + invert match sgtm, we have supported header match and query parameter match, there is no reason to block the address match. Although we could composite multiple different filters to achieve this similar target. But new cidr match could let most users' life easier.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
Has it really been solved? While https://github.com/envoyproxy/envoy/pull/43320 adds the feat, the CRD extension of BackendTrafficPolicy is still needed to be able to configure this. The only way I see for now to use it is EnvoyPatchPolicy, which is not a recommended way.