簡體   English   中英

如何使HPA根據其他部署生成的度量標准進行部署

[英]How to make HPA scale a deployment based on metrics produced by another deployment

我想要實現的是創建一個Horizo​​ntal Pod Autoscaler,它能夠根據controller pod生成的自定義指標擴展worker pod。

我已經有普羅米修斯刮,普羅米修斯Adapater,自定義度量服務器全面運作,縮放worker與自定義指標部署my_controller_metric由生產worker豆莢已經工作。

現在我的worker pod不再生成此度量標准,但controller確實如此。 似乎API autoscaling / v1不支持此功能。 如果需要,我可以使用autoscaling / v2beta1 API指定HPA。

這是我對此HPA的規范:

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: my-worker-hpa
  namespace: work
spec:
  maxReplicas: 10
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1beta1
    kind: Deployment
    name: my-worker-deployment
  metrics:
  - type: Object
    object:
      target:
        kind: Deployment
        name: my-controller-deployment
      metricName: my_controller_metric
      targetValue: 1

當使用kubectl apply -f my-worker-hpa.yml配置時,我收到消息:

horizontalpodautoscaler "my-worker-hpa" configured

雖然這個消息似乎沒問題,但HPA不起作用。 這個規范是否格式錯誤?

正如我所說,度量標准在自定義度量服務器中可用,帶有kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . | grep my_controller_metric kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . | grep my_controller_metric kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq . | grep my_controller_metric

這是來自HPA的錯誤消息:

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 my_controller_metric: Deployment on work my-controller-deployment/unable to fetch metrics from custom metrics API: the server could not find the metric my_controller_metric for deployments

謝謝!

在您的情況下,問題是HPA配置: spec.metrics.object.target還應指定API版本。 spec.metrics.object.target下放置apiVersion: extensions/v1beta1 spec.metrics.object.target應該修復它。

此外,還有一個關於HPA中更好的配置驗證的公開問題: https//github.com/kubernetes/kubernetes/issues/60511

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM