【问题标题】:Difficulty configuring Horizontal Pod Autoscaler with external metric难以使用外部指标配置 Horizo​​ntal Pod Autoscaler
【发布时间】:2019-03-31 18:52:30
【问题描述】:

我正在尝试配置 Horizo​​ntal 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


【解决方案1】:

您正在使用“类型:外部”。对于外部指标列表,您需要使用“kubernetes.io”而不是“container.googleapis.com”[1]

替换“metricName:container.googleapis.com|container|accelerator|duty_cycle”

‘metricName: kubernetes.io|container|accelerator|duty_cycle’

[1]https://cloud.google.com/monitoring/api/metrics_other#other-kubernetes.io

【讨论】:

    【解决方案2】:

    一旦我将系统置于负载下,这个问题就会自行消失。现在使用相同的配置可以正常工作。

    我不知道为什么。我的最佳猜测是 StackMetrics 直到超过 1% 才报告占空比值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-09
      • 1970-01-01
      • 2019-06-28
      相关资源
      最近更新 更多