Skip to content

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

@yehorkovalchuk777

Description

@yehorkovalchuk777

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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions