我像这里描述的那样设置我的HorizontalPodAutoscaler来根据来自我的发布/订阅的未确认消息的数量来监听尺度。我的愿望是,如果有超过1条未确认的消息,则pods可以扩展。当我运行k describe hpa时,我得到:
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"autoscaling/v2beta1","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"foobar-gke-prod","namespace":"defau...
CreationTimestamp: Mon, 25 May 2020 18:01:33 -0700
Reference: Deployment/foobar-gke-prod
Metrics: ( current / target )
"pubsub.googleapis.com|subscription|num_undelivered_messages" (target average value): 200m / 1
Min replicas: 3
Max replicas: 9
Deployment pods: 5 current / 5 desired返回的指标数据让我感到困惑。当我运行该命令时,根据控制台指标,未确认知识消息的数量约为4条。所以我不明白200m是什么意思?为什么不是4呢?
这是我对HPA的配置
# Template from https://cloud.google.com/kubernetes-engine/docs/tutorials/external-metrics-autoscaling
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: foobar-gke-prod
spec:
minReplicas: 3
maxReplicas: 9
metrics:
- external:
metricName: pubsub.googleapis.com|subscription|num_undelivered_messages
metricSelector:
matchLabels:
resource.labels.subscription_id: prod_foobar_subscription
targetAverageValue: "1"
type: External
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: foobar-gke-prod发布于 2020-05-26 18:23:20
参考示例:
Name: pubsub
...
Metrics: ( current / target )
"pubsub.googleapis.com|subscription|num_undelivered_messages" (target average value): 2250m / 2
Min replicas: 1
Max replicas: 4
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededRescale the HPA controller was able to update the target scale to 4
ScalingLimited True TooManyReplicas the desired replica count is more than the maximum replica count
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulRescale 7s horizontal-pod-autoscaler New size: 4; reason: external metric pubsub.googleapis.com|subscription|num_undelivered_messages(&LabelSelector{MatchLabels:map[string]string{resource.labels.subscription_id: echo-read,},MatchExpressions:[],}) above target(
返回的指标数据让我感到困惑。当我运行该命令时,根据控制台指标,未确认知识消息的数量约为4条。所以我不明白200m是什么意思?为什么不是4呢?
200m/1意味着在测量HPA时,每个运行的副本的平均未送达邮件数为0.2(20%)。Considerations:
如果你仍然认为这里的结果与更新后的hpa不匹配,请描述一下,我们可以再看一看。
编辑:
有没有办法使指标不是跨pods的平均值?也就是说,如果有5条未确认的消息,指标数据将读取5000m?
来自Kubernetes API参考ExternalMetricSource v2beta1 Autoscaling
targetAverageValue是全局指标的每个pod的目标值(因为quantity).targetValue是指标的目标值(以数量表示)。请注意,targetAverageValue和targetValue是互斥的。
因此,如果你想要总数而不是平均值,只需在你的HPA上调换它们。
https://stackoverflow.com/questions/62013168
复制相似问题