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 使用rabbitmq';s队列执行hpa,访问custom.metrics失败_Kubernetes_Rabbitmq_Prometheus_Prometheus Operator_Hpa - Fatal编程技术网

Kubernetes 使用rabbitmq';s队列执行hpa,访问custom.metrics失败

Kubernetes 使用rabbitmq';s队列执行hpa,访问custom.metrics失败,kubernetes,rabbitmq,prometheus,prometheus-operator,hpa,Kubernetes,Rabbitmq,Prometheus,Prometheus Operator,Hpa,可以通过api成功访问,通过/api/custom.metrics.k8s.io/v1beta1 kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/services/rabbitmq-exporter/rabbitmq_queue_messages_ready?metricLabelSelector=queue%3Dtest-1 | jq . { "kind": "MetricValueList

可以通过api成功访问,通过
/api/custom.metrics.k8s.io/v1beta1

kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/namespaces/default/services/rabbitmq-exporter/rabbitmq_queue_messages_ready?metricLabelSelector=queue%3Dtest-1 | jq .

{
  "kind": "MetricValueList",
  "apiVersion": "custom.metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/default/services/rabbitmq-exporter/rabbitmq_queue_messages_ready"
  },
  "items": [
    {
      "describedObject": {
        "kind": "Service",
        "namespace": "default",
        "name": "rabbitmq-exporter",
        "apiVersion": "/v1"
      },
      "metricName": "rabbitmq_queue_messages_ready",
      "timestamp": "2020-02-17T13:50:20Z",
      "value": "14",
      "selector": null
    }
  ]
}
HPA文件

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: test-hpa
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: test
  minReplicas: 1
  maxReplicas: 5
  metrics:
  - type: Object
    object:
      metric: 
        name: "rabbitmq_queue_messages_ready"
        selector: 
          matchLabels: 
            "queue": "test-1"
      describedObject:
        apiVersion: "custom.metrics.k8s.io/v1beta1"
        kind: Service
        name: rabbitmq-exporter
      target:
        type: Value
        value: 4
错误消息

Name:                                                                           test-hpa
Namespace:                                                                      default
Labels:                                                                         <none>
Annotations:                                                                    kubectl.kubernetes.io/last-applied-configuration:
                                                                                  {"apiVersion":"autoscaling/v2beta2","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"name":"test-hpa","namespace":"defa...
CreationTimestamp:                                                              Mon, 17 Feb 2020 21:38:08 +0800
Reference:                                                                      Deployment/test
Metrics:                                                                        ( current / target )
  "rabbitmq_queue_messages_ready" on Service/rabbitmq-exporter (target value):  <unknown> / 4
Min replicas:                                                                   1
Max replicas:                                                                   5
Deployment pods:                                                                1 current / 0 desired
Conditions:
  Type           Status  Reason                 Message
  ----           ------  ------                 -------
  AbleToScale    True    SucceededGetScale      the HPA controller was able to get the target's current scale
  ScalingActive  False   FailedGetObjectMetric  the HPA was unable to compute the replica count: unable to get metric rabbitmq_queue_messages_ready: Service on default rabbitmq-exporter/object metrics are not yet supported
Events:
  Type     Reason                        Age                   From                       Message
  ----     ------                        ----                  ----                       -------
  Warning  FailedComputeMetricsReplicas  97s (x12 over 4m22s)  horizontal-pod-autoscaler  Invalid metrics (1 invalid out of 1), last error was: failed to get object metric value: unable to get metric rabbitmq_queue_messages_ready: Service on default rabbitmq-exporter/object metrics are not yet supported
  Warning  FailedGetObjectMetric         82s (x13 over 4m22s)  horizontal-pod-autoscaler  unable to get metric rabbitmq_queue_messages_ready: Service on default rabbitmq-exporter/object metrics are not yet supported

名称:测试hpa
名称空间:默认值
标签:
注释:kubectl.kubernetes.io/last-applicated-configuration:
{“apiVersion”:“autoscaling/v2beta2”,“种类”:“HorizontalPodAutoscaler”,“元数据”:{“annotations”:{},“name”:“test hpa”,“namespace”:“defa…”。。。
CreationTimestamp:Mon,2020年2月17日21:38:08+0800
参考:部署/测试
指标:(当前/目标)
服务/rabbitmq导出器上的“rabbitmq\队列\消息\就绪”(目标值):/4
最小副本数:1
最大副本数:5
部署吊舱:1个当前吊舱/0个所需吊舱
条件:
键入状态原因消息
----           ------  ------                 -------
能够缩放真实成功缩放HPA控制器能够获取目标的当前缩放
ScalingActive False FailedGetObjectMetric HPA无法计算副本计数:无法获取度量rabbitmq\u队列\u消息\u就绪:默认rabbitmq导出器/对象度量上的服务尚不受支持
活动:
从消息中键入原因年龄
----     ------                        ----                  ----                       -------
警告FailedComputeMetricsReplicas 97s(x12超过4m22s)水平机架自动缩放器无效度量(1个无效,共1个),最后一个错误是:无法获取对象度量值:无法获取度量rabbitmq_队列_消息_就绪:默认rabbitmq导出器上的服务/对象度量尚不受支持
警告FailedGetObjectMetric 82s(x13超过4m22s)水平机架自动缩放器无法获取度量rabbitmq_队列_消息_就绪:默认rabbitmq导出器/对象度量上的服务尚不受支持

您在遵循什么文档/指南?您在运行什么kubernetes版本?看起来像是API版本错误。您在遵循什么文档/指南?您在运行什么kubernetes版本?看起来像是API版本错误。