Kubernetes autoscaling policies not working Kubernetes autoscaling policies not working kubernetes kubernetes

Kubernetes autoscaling policies not working


It works for me,

Client Version: v1.20.2Server Version: v1.18.9-eks-d1db3c

kubectl api-versions and my cluster also supports autoscaling/v2beta2

apiVersion: autoscaling/v2beta2kind: HorizontalPodAutoscalermetadata:  name: {{ template "ks.fullname" . }}-keycloakspec:  scaleTargetRef:    apiVersion: apps/v1    kind: Deployment    name: {{ template "ks.fullname" . }}-keycloak  minReplicas: {{ .Values.keycloak.hpa.minpods }}  maxReplicas: {{ .Values.keycloak.hpa.maxpods }}  metrics:  - type: Resource    resource:      name: memory      target:        type: Utilization        averageUtilization: {{ .Values.keycloak.hpa.memory.averageUtilization }}  - type: Resource    resource:      name: cpu      target:        type: Utilization        averageUtilization: {{ .Values.keycloak.hpa.cpu.averageUtilization }}  behavior:    scaleDown:      stabilizationWindowSeconds: {{ .Values.keycloak.hpa.stabilizationWindowSeconds }}      policies:        - type: Pods          value: 1          periodSeconds: {{ .Values.keycloak.hpa.periodSeconds }}{{- end }}


As already discussed in the comments, even with autoscaling/v2beta2 enabled this function will not work on version 1.14.

Starting from v1.18 the v2beta2 API allows scaling behavior to be configured through the HPA behavior field.

The easiest way out of it would be to upgrade to 1.18.


i wanted to implement HPA based on targetAverageValue what worked for me

while GKE version is around 1.12 to 1.14 you wont be able to apply manifest of autoscaling/v2beta2 however you can apply same thing something like

apiVersion: autoscaling/v2beta1kind: HorizontalPodAutoscalermetadata:  name: core-deployment  namespace: defaultspec:  maxReplicas: 9  minReplicas: 5  scaleTargetRef:    apiVersion: extensions/v1beta1    kind: Deployment    name: core-deployment  metrics:  - type: Resource    resource:      name: cpu      targetAverageValue: 500m