nginx 入口速率限制

nginx ingress rate limiting

我无法理解 Nginx ingress

rate-limiting 中的一点

我指的是一篇关于 nginx 入口速率限制的文章:https://medium.com/titansoft-engineering/rate-limiting-for-your-kubernetes-applications-with-nginx-ingress-2e32721f7f57#:~:text=When%20we%20use%20NGINX%20ingress,configure%20rate%20limits%20with%20annotations.&text=As%20an%20example%20above%2C%20the,qps)%20on%20the%20Hello%20service。

最后在限制部分

It applies to the whole ingress and is not able to configure exceptions, eg. when you want to exclude a health check path /healthz from your service.

如果我创建两个 ingresses 具有不同的 names,其中一个具有路径 /hello1和另一个 /hello2 都指向 相同的服务后端 .

现在如果我只对一个入口或路径添加速率限制 /hello1 会影响另一个吗?如果有相同的 主机或域 ???

入口 1example.com/hello1 - 速率限制设置

入口 2example.com/hello2 无速率限制

提前致谢

速率限制将仅应用于您指定的入口。基本上 nginx-ingress 在后台做什么 - 它将规则合并到 1 个巨大的配置中,但是它们适用于不同的对象。

例如,同一主机和差异路径有 2 个不同的入口。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test1
  annotations:
    kubernetes.io/ingress.class: 'nginx'
    nginx.ingress.kubernetes.io/limit-rps: '5'
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /path1
        backend:
          serviceName: service1
          servicePort: 8080

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test2
  annotations:
    kubernetes.io/ingress.class: 'nginx'
    nginx.ingress.kubernetes.io/limit-rps: '10'
spec:
  rules:
  - host: example.com
    http:
      paths:
      - path: /path2
        backend:
          serviceName: service1
          servicePort: 8080