kong rate limiting plugin has no effect on request

8/8/2021

I have deployed the following resources. 1) kong in kong namespace 2) service echo in poc namespace

 ```kubectl apply -f https://gist.githubusercontent.com/hbagdi/0d833181239a39172ba70cbec080bdb9/raw/7f46cf1c9e54562e2c23902daace7ac8edc40427/echo-server.yaml -n poc```

3) Created an ingress with /foo path in poc namespace. Note: /foo is mapped to /echo from echo service.

    echo "
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: demo
      namespace: poc
      annotations:
        kubernetes.io/ingress.class: kong
    spec:
      rules:
      - http:
          paths:
          - path: /foo
            backend:
              serviceName: echo
              servicePort: 80
    " | kubectl -n poc apply -f -

4) Created the kong plugin

kind: KongPlugin
metadata:
  name: default.rate-limiting
  namespace: poc
config:
  minute: 3
  policy: local
plugin: rate-limiting" | kubectl apply -f -

5) Patched the service with the default.rate-limiting kubectl patch -n poc svc echo -p '{"metadata":{"annotations":{"konghq.com/plugins": "default.rate-limiting"}}}'

As per above logic, 3 request in a minute should be allowed however rate-limiting is not being applied even for more than 3 requests in a minute.

-- Rajiv Rai
kong
kong-plugin
kubernetes
rate-limiting

1 Answer

8/8/2021

i not sure which model you are using for Kong with DB or DB less.

First, i would suggest you trying out once Konga which is a dashboard for Kong to manage instead of managing using files.

Read more at : https://faun.pub/kong-api-gateway-with-konga-dashboard-ae95b6d1fec7

On rate limit, I have faced the same issue with policy type local as it's don't use any type of database in the background.

there is open issue on GitHub : https://github.com/Kong/kong/issues/5311

https://docs.konghq.com/hub/kong-inc/rate-limiting/#configuration

try using the Redis once in the background with rate limiting and test a few scenarios changing the request by seconds and minutes.

-- Harsh Manvar
Source: StackOverflow