Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 使用外部度量配置水平吊舱自动缩放仪有困难_Kubernetes_Google Kubernetes Engine - Fatal编程技术网

Kubernetes 使用外部度量配置水平吊舱自动缩放仪有困难

Kubernetes 使用外部度量配置水平吊舱自动缩放仪有困难,kubernetes,google-kubernetes-engine,Kubernetes,Google Kubernetes Engine,我正在尝试配置一个水平吊舱自动缩放器,以根据连接的GPU的占空比扩展部署 我使用的是GKE,我的Kubernetes主版本是1.10.7-GKE.6 我正在学校里完成教程。特别是,我运行了以下命令来设置自定义指标: kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/produ

我正在尝试配置一个水平吊舱自动缩放器,以根据连接的GPU的占空比扩展部署

我使用的是GKE,我的Kubernetes主版本是1.10.7-GKE.6

我正在学校里完成教程。特别是,我运行了以下命令来设置自定义指标:

kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
这似乎奏效了,或者至少我可以访问/api/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的存在是因为它列在/api/custom.metrics.k8s.io/v1beta1中,并且在上有描述

这是我在描述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

我真的不知道如何调试这个。是否有人知道可能有什么问题,或者我下一步可以做什么?

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

替换“metricName:container.googleapis.com | container |加速器|占空比”

“metricName:kubernetes.io |容器|加速器|占空比”


[1]

一旦我将系统加载,这个问题就自行解决了。在相同的配置下,它现在工作正常


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

一切看起来都不错,您启用了stackdriver吗?您能够解决这个问题吗?我做到了,在下面的回答中添加了解决方案。这在我的案例中起到了作用:)