We use Envoy rate limit service to limit the number of requests hitting our service.
Deployment is similar to this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: envoy-rate-limiter
spec:
replicas: 2
selector:
matchLabels:
service: envoy-rate-limiter
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
service: envoy-rate-limiter
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: service
operator: In
values:
- router-$(ConfigMap.BRANCH)
topologyKey: kubernetes.io/hostname
securityContext:
runAsUser: 1001
fsGroup: 1001
containers:
- name: envoy-rate-limiter
image: envoyproxy/ratelimit:e059638d
imagePullPolicy: Always
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 8081
name: grpc
protocol: TCP
volumeMounts:
- name: ratelimit-config
mountPath: /data/ratelimit/config
readOnly: true
env:
- name: REDIS_TLS
value: "false"
command: ["/bin/ratelimit"]
volumes:
- name: ratelimit-config
configMap:
name: ratelimit-config
Configuration of rate limit service is basically this:
apiVersion: v1
kind: ConfigMap
metadata:
name: ratelimit-config
data:
config: |
---
domain: router
descriptors:
- key: "METHOD"
rate_limit:
unit: second
requests_per_unit: 2000
name: overall_limit
I'd like the value of requests_per_unit to change if some other services scales up. How can I achieve it?