我正在尝试在 kubernetes 环境中为我的 statefulset(用于 elasticsearch)设置 HPA。我计划使用 cpu 利用率来扩展 statefulset。我从https://github.com/stefanprodan/k8s-prom-hpa/tree/master/metrics-server创建了度量服务器。
我的 statefulset 的 HPA yaml 如下:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: dz-es-cluster
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: StatefulSet
name: dz-es-cluster
minReplicas: 2
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
但是在 hpa 中得到如下输出:
Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale False FailedGetScale the HPA controller was unable to get the target's current scale: the server could not find the requested resource
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedGetScale 1m (x71 over 36m) horizontal-pod-autoscaler the server could not find the requested resource
有人请帮助我..