[英]How to make HPA scale a deployment based on metrics produced by another deployment
我想要实现的是创建一个Horizontal 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.