Home > Net >  set rate-limits for specific apis in kubernetes nginx
set rate-limits for specific apis in kubernetes nginx

Time:12-13

I am currently using nginx-ingress-controller in my eks-cluster. I want to set rate-limits for only specific apis like /healthz like mentioned here and not only all my APIs.

Is there a way i can do it?

Thanks in advance

CodePudding user response:

For separate specific you can make another ingress resource

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/limit-rps: "15"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  labels:
    name: ingress
  name: ingress
spec:
  rules:
  - host: healthz.example.io
    http:
      paths:
      - backend:
          serviceName: hello
          servicePort: 80
        path: /healthz

While you can make one ingress resource for other API, without rate limit setup

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  labels:
    name: ingress-2
  name: ingress-2
spec:
  rules:
  - host: healthz.example.io
    http:
      paths:
      - backend:
          serviceName: hello
          servicePort: 80
        path: /data
      - backend:
          serviceName: hello
          servicePort: 80
        path: /api
  • Related