How to use rate limit for a single api | Kong Ingress Controller | Rate Limit Plugin


I am using Path and Host-Based Routing in the Kong ingress controller. Below is the sample file

apiVersion: extensions/v1beta1
kind: Ingress
name: app1
namespace: app
annotations: “true” kong

  • host:
    • path: /api
      serviceName: app1-service
      servicePort: 80


I want to apply a rate limit on a single API. i.e

The rest of the APIs should work as usual. i.e. No Rate limit for these endpoints. , /api/v3

Note: I am using strip path annotation in the ingress rule.

How can I achieve this using the Rate limit Plugin? Any help would be appreciated.

Hi Akshay,

You can follow the official doc and apply rate-limiting-plugin-name annotation to your ingress. That way the rate limiting plugin will only be applied on this ingress object which is the route.

@fomm Thanks for your response.

this is the only concern. rate limit plugin will be applied on every request with /api.

I want it to be applied only on /api/v1, not on /api/v2/register or /api/v3/login

Ingress doesn’t provide any way to add configuration for specific rules beyond the settings exposed by Ingress itself (effectively just the rule path and associated backend Service). Annotations, which are the only way to add vendor-specific configuration (such as Kong plugin configurations) must be configured at the Ingress level, and apply to all rules in that Ingress. You cannot apply them to a subset of an Ingress’s rules only.

As such, to apply that plugin to some rules and not others, you will need multiple Ingresses covering different paths in your application’s API. You’ll apply the rate limiting configuration only to the Ingress that contains rules you want to throttle.

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ