我设置了我的 HorizontalPodAutoscaler,如下所述https://cloud.google.com/kubernetes-engine/docs/tutorials/external-metrics-autoscaling根据来自我的 Pub/Sub 的未确认消息的数量来监听缩放。我的愿望是,如果有超过 1 条未确认的消息,则 pod 会扩展。当我跑步时,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