Ambassador Rate limitting not working properly

Viewed 315

I am trying to do rate-limiting with ambassador following this tutorial. I am using minikube and local docker image.I have tested all api is responding correctly after deploying to Kubernetes only the rate-limiting function isn't working.

Here is my deploy.yaml

---
apiVersion: v1
kind: Service
metadata:
  name: nodejs-deployment
spec:
  ports:
  - name: http
    port: 80
    targetPort: 3000
  - name: https
    port: 443
    targetPort: 3000
  selector:
    app: nodejs-deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nodejs-deployment
spec:
  selector:
    matchLabels:
      app: nodejs-deployment
  replicas: 2
  template:
    metadata:
      labels:
        app: nodejs-deployment  
    spec:
      containers: 
      - name: nodongo
        image: soham/nodejs-starter
        imagePullPolicy: "Never"
        ports:
        - containerPort: 3000

Here is my rate-limit.yaml

---

apiVersion: getambassador.io/v2

kind: Mapping

metadata:

  name: nodejs-backend

spec:

  prefix: /delete/

  service: nodejs-deployment

  labels:

    ambassador:

      - request_label_group:

        - delete

---

apiVersion: getambassador.io/v2

kind: RateLimit

metadata:

  name: backend-rate-limit

spec:

  domain: ambassador

  limits:

  - pattern: [{generic_key: delete}]

    rate: 1

    unit: minute

    injectResponseHeaders:

    - name: "x-test-1"

      value: "my-rl-test"

When I am executing the command -- curl -vLk 10.107.60.125/delete/

It is returning

*   Trying 10.107.60.125:80...
* TCP_NODELAY set
* Connected to 10.107.60.125 (10.107.60.125) port 80 (#0)
> GET /delete/ HTTP/1.1
> Host: 10.107.60.125
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: text/html; charset=utf-8
< Content-Length: 11
< ETag: W/"b-CgqQ9sWpkiO3HKmStsUvuC/rZLU"
< Date: Tue, 03 Nov 2020 17:13:00 GMT
< Connection: keep-alive
< 
* Connection #0 to host 10.107.60.125 left intact
Delete User

The response I am getting is 200 however I am expecting 429 error code.

0 Answers
Related