apisix icon indicating copy to clipboard operation
apisix copied to clipboard

help request: Set request rate limit by service or upstream via Ingress Controller

Open yehorkovalchuk777 opened this issue 1 year ago • 1 comments

Description

Here is an example of limit-req plugin configuration deployed via ApisixGlobalRule

apiVersion: apisix.apache.org/v2
kind: ApisixGlobalRule
metadata:
  name: apisix-global-plugins
  namespace: ingress-apisix
spec:
  plugins:
    - name: limit-req
      enable: true
      config:
        rate: 20
        burst: 50
        key_type: "var"
        key: "remote_addr"
        rejected_code: 503

Here we use the remote_addr variable, which limits the number of requests per client But we need to limit the number of requests per service (or upstream) We could use the service_id, service_name or upstream_addr variables, but all these variables are nil However, it is impossible to set the service_id for the route directly, because the ApisixRoute CRD does not have such a field How can we set request rate limit per service/upstream in this case?

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

yehorkovalchuk777 avatar Sep 26 '24 12:09 yehorkovalchuk777