【发布时间】:2020-01-12 03:51:27
【问题描述】:
我在 Google Kubernetes Engine 上有以下 Horizontal Pod Autoscaler 配置,可通过自定义指标扩展部署 - RabbitMQ messages ready count 用于特定队列:foo-queue。
它正确地获取度量值。
当插入 2 条消息时,它会将部署扩展到最多 10 个副本。 我希望它可以扩展到 2 个副本,因为 targetValue 是 1 并且有 2 条消息准备好了。
为什么它会如此积极地扩展?
HPA 配置:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: foo-hpa
namespace: development
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: foo
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metricName: "custom.googleapis.com|rabbitmq_queue_messages_ready"
metricSelector:
matchLabels:
metric.labels.queue: foo-queue
targetValue: 1
【问题讨论】:
-
你确定
targetValue: 1?为什么这个值这么小?我看到推荐值超过 100 的样本 -
@Yasen 当设置
targetValue: 100并在队列中有 2 条消息时,HPA 扩展到 2 个 pod,这似乎非常激进,我希望它是 1 个副本 -
请您阅读前 Docker 开发人员 Jérôme Petazzoni 的本指南:Kubernetes Deployments: The Ultimate Guide - Semaphore。它解释了为什么在
k8s中有两个副本,而在docker中没有一个副本
标签: kubernetes rabbitmq google-kubernetes-engine kubernetes-hpa