Reputation: 445
I am new to Kubernetes, and planning on moving some of my ECS services to EKS. In my current auto-scaling algorithm, apart from CPU, memory and some other things I also used rate of incoming requests. In Kubernetes, how can I leverage rate of incoming requests to customize auto-scaling?
Upvotes: 1
Views: 1609
Reputation: 30120
You can use the Prometheus adapter along with the HPA to scale the deployment based on incoming requests or other metrics you want.
https://github.com/kubernetes-sigs/prometheus-adapter/blob/master/docs/walkthrough.md
also do check this out : https://github.com/zalando-incubator/kube-metrics-adapter
Example
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: myapp-hpa
annotations:
# metric-config.<metricType>.<metricName>.<collectorType>/<configKey>
metric-config.pods.requests-per-second.json-path/json-key: "$.http_server.rps"
metric-config.pods.requests-per-second.json-path/path: /metrics
metric-config.pods.requests-per-second.json-path/port: "9090"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myapp
minReplicas: 1
maxReplicas: 10
metrics:
- type: Pods
pods:
metric:
name: requests-per-second
target:
averageValue: 1k
type: AverageValue
Upvotes: 2