Istio 阻止来自单个 IP 的过多请求

问题描述 投票:0回答:1

我需要为单个IP可以触发的请求数量设置速率限制。

我按照 Istio 文档中的本教程进行了全局速率限制。 https://istio.io/latest/docs/tasks/policy-enforcement/rate-limit/

我使用此文件部署了速率限制服务,在上面的链接中共享。 https://github.com/istio/istio/blob/release-1.12/samples/ratelimit/rate-limit-service.yaml

下面共享的配置映射工作正常,但一旦达到限制,它就会阻止来自所有 IP 地址的请求。我需要阻止尝试发送超过定义数量的请求的 IP。

apiVersion: v1
kind: ConfigMap
metadata:
  name: ratelimit-config
data:
  config.yaml: |
    domain: productpage-ratelimit
    descriptors:
      - key: PATH
        value: "/productpage"
        rate_limit:
          unit: minute
          requests_per_unit: 1
      - key: PATH
        rate_limit:
          unit: minute
          requests_per_unit: 100

我按照此链接上的示例 3 更新了上述配置https://github.com/envoyproxy/ratelimit#example-3。之后我也重新启动了速率限制服务和 istio pod。我尝试访问此后的网址,但它并没有阻止我的请求。

apiVersion: v1
kind: ConfigMap
metadata:
  name: ratelimit-config
data:
  config.yaml: |
    domain: edge_proxy_per_ip
    descriptors:
      - key: remote_address
        rate_limit:
          requests_per_unit: 1
          unit: minute

当我尝试打开 URL 时,速率限制服务的日志。

Istio版本:1.12.1 库伯内特版本: 客户端版本:v1.22.2 服务器版本:v1.21.2-eks-06eac09 –

kubernetes amazon-eks istio rate-limiting envoyproxy
1个回答
0
投票

查看日志,我猜您还需要更新 envoy 过滤器以发送包含客户端 IP 的描述符。

rate_limits:
- actions:
  - request_headers:
      header_name: ':path'
      descriptor_key: 'PATH'
  - remote_address: {}
© www.soinside.com 2019 - 2024. All rights reserved.