I've added some scaling policies to my HorizontalPodAutoscaler but they are not being applied. The scaleUp and scaleDown behaviours are being ignored. I need a way to stop pods scaling up and down every few minutes in response to small CPU spikes. Ideally the HPA would scale up quickly in response to more traffic but scale down slowly after about 30 minutes of reduced traffic.
I'm running this on an AWS EKS cluster and I have setup the policies according to https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior.
Could this be a limitation of EKS or my K8s version which is 1.14. I have run kubectl api-versions
and my cluster does support autoscaling/v2beta2.
My Helm spec is:
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "app.fullname" . }}
labels:
app: {{ template "app.name" . }}
chart: {{ template "app.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1beta2
kind: Deployment
name: "{{ template "app.fullname" . }}-server"
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageValue: 200m
behavior:
scaleUp:
stabilizationWindowSeconds: 300
policies:
- type: Pods
value: 1
periodSeconds: 300
scaleDown:
stabilizationWindowSeconds: 1200
policies:
- type: Pods
value: 1
periodSeconds: 300
As already discussed in the comments, even with
autoscaling/v2beta2
enabled this function will not work on version 1.14.The easiest way out of it would be to upgrade to 1.18.