Kubernetes GKE K8 HPA无法获取stackdriver度量

Kubernetes GKE K8 HPA无法获取stackdriver度量,kubernetes,google-cloud-platform,google-kubernetes-engine,Kubernetes,Google Cloud Platform,Google Kubernetes Engine,我们有一个k8 gke集群,我们希望我们的pod能够通过应用程序逻辑向stackdriver公开的自定义度量进行扩展 我能够推动度量,并能够在度量资源管理器中查看 形象 我们可以在k8自定义度量列表中看到度量 kubectl get--raw/api/custom.metrics.k8s.io/v1beta1 | python-m json.tool | grep-a10 num_drivers_per|u pod { "kind": "MetricValueList",

我们有一个k8 gke集群,我们希望我们的pod能够通过应用程序逻辑向stackdriver公开的自定义度量进行扩展

我能够推动度量,并能够在度量资源管理器中查看 形象

我们可以在k8自定义度量列表中看到度量 kubectl get--raw/api/custom.metrics.k8s.io/v1beta1 | python-m json.tool | grep-a10 num_drivers_per|u pod

{
            "kind": "MetricValueList",
            "name": "*/custom.googleapis.com|num_drivers_per_pod",
            "namespaced": true,
            "singularName": "",
            "verbs": [
                "get"
            ]
        }
我们已经成功安装了stackdriver适配器,并与heapster一起运行

但是当我们部署给定的HPA清单时

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: custom-metric-sd-num-drivers
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: apps/v1beta1
    kind: Deployment
    name: test-ws-api-server
  minReplicas: 1
  maxReplicas: 5
  metrics:
    - type: Pods
      pods:
        metricName: "num_drivers_per_pod"
        targetAverageValue: 2
k8群集无法获取具有以下消息的度量

Name:               custom-metric-sd-num-drivers
Namespace:          default
Labels:             <none>
Annotations:        autoscaling.alpha.kubernetes.io/conditions:
                      [{"type":"AbleToScale","status":"True","lastTransitionTime":"2020-01-07T14:26:25Z","reason":"SucceededGetScale","message":"the HPA control...
                    autoscaling.alpha.kubernetes.io/current-metrics:
                      [{"type":"External","external":{"metricName":"custom.googleapis.com|num_drivers_per_pod","currentValue":"0","currentAverageValue":"1"}}]
                    autoscaling.alpha.kubernetes.io/metrics: [{"type":"Pods","pods":{"metricName":"num_drivers_per_pod","targetAverageValue":"2"}}]
                    kubectl.kubernetes.io/last-applied-configuration:
                      {"apiVersion":"autoscaling/v2beta1","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"custom-metric-sd-num-drivers","n...
CreationTimestamp:  Tue, 07 Jan 2020 19:56:10 +0530
Reference:          Deployment/test-ws-api-server
Min replicas:       1
Max replicas:       5
Deployment pods:    1 current / 1 desired
Events:
  Type     Reason               Age                   From                       Message
  ----     ------               ----                  ----                       -------
  Warning  FailedGetPodsMetric  47s (x6237 over 27h)  horizontal-pod-autoscaler  unable to get metric num_drivers_per_pod: no metrics returned from custom metrics API
你们能告诉我该去哪里看,以及是什么导致了这个问题吗

Hey刚刚解决了这个问题,将部署版本迁移回gke_容器资源类型。我已经用python发布了一个简单的回购协议,以实现与我发现的描述类似问题的相同功能

可能存在与“external.metrics”和“custom.metrics”相关的混淆

此处类型设置为“外部”,但名称表示“自定义”:

应该查看HorizontalPodAutoscaler中的“type:”值

对于自定义度量,它应该表示“类型:对象”,对于外部度量,它应该表示“类型:外部”

编辑 据我所知,这里有四件事:
-MetricValueList
-Stackdriver度量资源管理器
-水平足自动缩放仪
-Python脚本

由于可以在度量资源管理器中查看度量,因此排除了MetricValueList和Python脚本的问题

知道了这一点,问题很可能出现在HorizontalPodAutoscaler或其周围

此命令未返回任何项这一事实是一个问题

kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/num_drivers_per_pod"

您是否能够使用wget从服务端点(在您的情况下是自定义度量Stackdriver适配器)手动检索度量?您的问题与此类似您的意思是-->
kubectl get--raw”/api/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/num\u drivers\u per\u pod“
{“kind”:“MetricValueList”,“apiVersion”:“custom.metrics.k8s.io/v1beta1”,“metadata”:{“selfLink”:”:“/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/%2A/num\u drivers\u per\u pod”},“items”:[]}
我可以获取指标,但没有项目(pods)在itI am follow中,它说应该使用类型pods,我尝试运行相同的教程,它能够获取HPA度量,区别在于我的度量生成器是python,python发布有什么问题,我能够在度量资源管理器中看到度量
[{"type":"External","external":{"metricName":"custom.googleapis.com
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/pods/*/num_drivers_per_pod"