【发布时间】:2019-03-31 18:52:30
【问题描述】:
我正在尝试配置 Horizontal Pod Autoscaler 以根据所连接 GPU 的占空比扩展部署。
我正在使用 GKE,我的 Kubernetes 主版本是 1.10.7-gke.6 。
我正在完成https://cloud.google.com/kubernetes-engine/docs/tutorials/external-metrics-autoscaling 的教程。特别是,我运行了以下命令来设置自定义指标:
kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
这似乎奏效了,或者至少我可以在 /apis/custom.metrics.k8s.io/v1beta1 访问指标列表。
这是我的 YAML:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: images-srv-hpa
spec:
minReplicas: 1
maxReplicas: 10
metrics:
- type: External
external:
metricName: container.googleapis.com|container|accelerator|duty_cycle
targetAverageValue: 50
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: images-srv-deployment
我相信 metricName 存在是因为它在 /apis/custom.metrics.k8s.io/v1beta1 中列出,并且因为它在 https://cloud.google.com/monitoring/api/metrics_gcp 中进行了描述。
这是我在描述 HPA 时遇到的错误:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetExternalMetric 18s (x3 over 1m) horizontal-pod-autoscaler unable to get external metric prod/container.googleapis.com|container|accelerator|duty_cycle/nil: no metrics returned from external metrics API
Warning FailedComputeMetricsReplicas 18s (x3 over 1m) horizontal-pod-autoscaler failed to get container.googleapis.com|container|accelerator|duty_cycle external metric: unable to get external metric prod/container.googleapis.com|container|accelerator|duty_cycle/nil: no metrics returned from external metrics API
我真的不知道如何进行调试。有谁知道可能出了什么问题,或者我接下来可以做什么?
【问题讨论】:
-
一切看起来都不错,您是否启用了 stackdriver?
-
你能解决这个问题吗?
-
我做了,在下面的答案中添加了分辨率。
标签: kubernetes google-kubernetes-engine