I am trying to setup HPA for my statefulset(for elasticsearch) in kubernetes environment. I am planning to scale the statefulset using the cpu utilization. I have created the metric server from https://github.com/stefanprodan/k8s-prom-hpa/tree/master/metrics-server.
and my HPA yaml for statefulset is as folows:
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
But getting output in hpa as follows:
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
someone please help me..
kubectl top nodes
? – Prafull Ladharoot@ip:~# kubectl top nodes NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% ip-***-20-32-***.ec2.internal 1454m 9% 18392Mi 28% ip-***-20-34-***.ec2.internal 2130m 13% 31761Mi 49%
– manu thankachanresources
section in your statefulset. That is required section for HPA to work. kubernetes.io/docs/concepts/configuration/… – Prafull Ladha