k8s 使用 Prometheus custom metrics 配置 HPA 自动伸缩遇到问题
毕业设计
1
使用下面的 yaml 配置
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: blog-web
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: blog-web
minReplicas: 5
maxReplicas: 12
metrics:
- type: Pods
pods:
metricName: http_requests
targetAverageValue: 100
用 kubectl apply -f hpa-blog-web.yaml 命令部署时却报错
error: error validating "hpa-blog-web.yaml": error validating data: [ValidationError(HorizontalPodAutoscaler.spec.metrics[0].pods): unknown field "metricName" in io.k8s.api.autoscaling.v2beta2.PodsMetricSource, ValidationError(HorizontalPodAutoscaler.spec.metrics[0].pods): unknown field "targetAverageValue" in io.k8s.api.autoscaling.v2beta2.PodsMetricSource, ValidationError(HorizontalPodAutoscaler.spec.metrics[0].pods): missing required field "metric" in io.k8s.api.autoscaling.v2beta2.PodsMetricSource, ValidationError(HorizontalPodAutoscaler.spec.metrics[0].pods): missing required field "target" in io.k8s.api.autoscaling.v2beta2.PodsMetricSource]; if you choose to ignore these errors, turn validation off with --validate=false
请问如何解决?
注: Kubernetes 版本是 1.17.0
发表回复