How to configure Rate limiting plugin for Route+Consumer

Hi,

I’ve deployed the Kong Ingress controller on my Kubernetes cluster. I’m trying to configure the rate-limiting plugin for a specific consumer on a specific ingress route. I’ve tried the following:

apiVersion: configuration.konghq.com/v1
kind: KongConsumer
credentials:
  - credential
custom_id: "10"
metadata:
  name: user-consumer
username: myuser

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: protected-api
  annotations:
    konghq.com/strip-path: "false"
    konghq.com/plugins: global-cors, app-jwt
spec:
  rules:
    - host: api.host.com
      http:
        paths:
          - path: /me
            backend:
              serviceName: api
              servicePort: 80

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: rate-limit
config:
  minute: 5
  policy: local
consumerRef: user-consumer
plugin: rate-limiting

I’ve tried setting the plugin annotation on the consumer and the ingress resource, but I always end up with either rate-limiting for all my consumers or with the consumer being limited in all routes.

Using the admin api on a regular kong deployment outside k8s I was able to do this by configuring the plugin to only work on a specific route and for a specific consumer.

  1. Configure a rate-limiting (let’s say 5 req per min) on the ingress resource
  2. Configure a new rate-limtiing plugin, 10 rpm for the consumer, now specify the plugin name in konghq.com/plugins annotation on both resources - the consumer and the ingress resource.

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ