简体   繁体   English

对于“超过 63 个字符”的指标,通过 custom-metrics-stackdriver-adapter 进行水平 Pod 自动缩放失败

[英]Horizontal Pod Autoscaling via custom-metrics-stackdriver-adapter fails for metrics "more than 63 characters"

I have a Kubernetes cluster running in Google Kubernetes Engine where I wish to scale a deployment based on the number of messages a GCP Pub/Sub subscription has outstanding.我有一个在 Google Kubernetes Engine 中运行的 Kubernetes 集群,我希望根据 GCP Pub/Sub 订阅未完成的消息数量来扩展部署。 I found and followed a guide from Google covering exactly this scenario which involves deploying the custom-metrics-stackdriver-adapter .我找到并遵循了 Google 的指南,涵盖了这个场景,其中涉及部署custom-metrics-stackdriver-adapter

However, because my subscriptions name is over 63 characters in length when I run kubectl describe hpa <MY_HPA_NAME> I get the following events.但是,因为当我运行kubectl describe hpa <MY_HPA_NAME>时我的订阅名称长度超过 63 个字符,我收到以下事件。

Events:
  Type     Reason                        Age                From                       Message
  ----     ------                        ----               ----                       -------
  Warning  FailedGetExternalMetric       12s (x2 over 27s)  horizontal-pod-autoscaler  invalid label value: "<MY_VERBOSE_SUBSCRIPTION_NAME>": must be no more than 63 characters
  Warning  FailedComputeMetricsReplicas  12s (x2 over 27s)  horizontal-pod-autoscaler  failed to get pubsub.googleapis.com|subscription|num_undelivered_messages external metric: invalid label value: "<MY_VERBOSE_SUBSCRIPTION_NAME>": must be no more than 63 characters

How do I go about using a Subscription name which is over 63 characters as a metric to trigger HPA?如何使用超过 63 个字符的订阅名称作为触发 HPA 的指标?

Extra questions额外问题

I did try looking into what metric values where being exposed but when I queried Kubernetes Custom Metrics API I can't see any actual values for that metric by doing the following:我确实尝试查看公开的指标值,但是当我查询 Kubernetes 自定义指标 API 时,通过执行以下操作,我看不到该指标的任何实际值:

$ kubectl get --raw "http://localhost:8001/apis/custom.metrics.k8s.io/v1beta1/namespaces/*/pods/*/pubsub.googleapis.com|subscription|num_undelivered_messages" | jq .

{
  "kind": "MetricValueList",
  "apiVersion": "custom.metrics.k8s.io/v1beta1",
  "metadata": {
    "selfLink": "/apis/custom.metrics.k8s.io/v1beta1/namespaces/%2A/pods/%2A/pubsub.googleapis.com%7Csubscription%7Cnum_undelivered_messages"
  },
  "items": []
}

However, as you can see this returned an empty "items" lists suggesting there were no values recorded.但是,正如您所看到的,这返回了一个空的"items"列表,表明没有记录任何值。 I assumed that this was due to all of my subscription names being over 63 characters in length.我认为这是因为我的所有订阅名称的长度都超过 63 个字符。 To test this I made a new subscription with a very short name and recreated the HPA to be triggered by this new subscription.为了测试这一点,我用一个非常短的名称创建了一个新订阅,并重新创建了由这个新订阅触发的 HPA。 This time the pods actually scaled how I expected but when I queried the Custom Metric API as above it still returned and empty "items" list.这次 pods 实际上按我的预期进行了缩放,但是当我如上所述查询自定义指标 API 时,它仍然返回并为空的"items"列表。

Should I expect to see values in that response (and their labels)?我应该期望在该响应(及其标签)中看到值吗? How was Kubernetes able to scale the pods if no "items" were present?如果不存在"items" ,Kubernetes 如何扩展 Pod?

Here is design documentation of the kubernetes.这是 kubernetes 的设计文档 There is no way to avoid the restriction other than shortening the label name.除了缩短标签名称之外,没有办法避免这种限制。

rfc1035/rfc1123 label (DNS_LABEL): An alphanumeric (az, and 0-9) string, with a maximum length of 63 characters, with the '-' character allowed anywhere except the first or last character, suitable for use as a hostname or segment in a domain name. rfc1035/rfc1123 标签(DNS_LABEL):一个字母数字(az 和 0-9)字符串,最大长度为 63 个字符,除了第一个或最后一个字符外,任何地方都允许使用“-”字符,适合用作主机名或域名中的段。

Check the External Metrics API instead of Custom Metrics API for metrics items.检查外部指标 API 而不是自定义指标 API 以获取指标项。

$ kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq

https://itnext.io/google-kubernetes-engine-horizontalpodautoscaler-with-external-metrics-from-pubsub-28780c300305 https://itnext.io/google-kubernetes-engine-horizo​​ntalpodautoscaler-with-external-metrics-from-pubsub-28780c300305

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有自定义指标的水平 pod 自动缩放 - Horizontal pod Autoscaling without custom metrics 如何在外部指标上实现 Horizontal Pod Autoscaling? - How to implment Horizontal Pod Autoscaling on external metrics? 基于 Kubernetes 指标的 Google Cloud GKE 水平 pod 自动缩放 - Google cloud GKE horizontal pod autoscaling based on Kubernetes metrics 如何在 Kubernetes Horizontal Pod Autoscaling 中排除某些容器的指标 - How to exclude some containers' metrics in Kubernetes Horizontal Pod Autoscaling 可以从指标服务器获取哪些指标以进行水平Pod自动缩放 - What metrics can be fetched from metrics-server for Horizontal Pod Autoscaling OpenShift中水平Pod自动缩放器的自定义指标 - custom metrics for horizontal pod autoscaler in OpenShift Minikube 水平 pod 自动缩放错误:无法获取资源 cpu 的指标:未返回指标 - Minikube horizontal pod autoscaling error: unable to get metrics for resource cpu: no metrics returned 水平 pod 自动缩放不起作用:`无法获取资源 cpu 的指标:没有从 heapster 返回指标` - Horizontal pod autoscaling not working: `unable to get metrics for resource cpu: no metrics returned from heapster` 使用InfluxDB进行Horizaontal Pod AutoScaling使用自定义指标 - Using InfluxDB for Horizaontal Pod AutoScaling using Custom Metrics 使用 Prometheus Adapter 的 Horizo​​ntal Pod Autoscaler (HPA) 自定义指标(如何定义单位?) - Horizontal Pod Autoscaler (HPA) custom metrics with Prometheus Adapter (How are units defined?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM