Kubernetes pod auto scale down

We have deployed our microservicers on AKS and enabled Horizontal Pod Autoscaling (HPA) based on memory Utilization. The pods are automatically scaled up when utilization reaches the specified percentage, but they don’t scale down even when utilization fall below the percentage

Please find hpa file.

{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.fullName }}
namespace: {{ .Values.namespace }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.fullName }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}

  • type: Resource
    resource:
    name: memory
    target:
    type: Utilization
    averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
    {{- end }}
    {{- end }}
    behavior:
    scaleDown:
    stabilizationWindowSeconds: 60
    policies:
    • type: Pods
      value: 1
      periodSeconds: 60
      scaleUp:
      stabilizationWindowSeconds: 60
      policies:
    • type: Pods
      value: 1
      periodSeconds: 60

Values file.

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
annotations:
labels:
name: XXXXX
namespace: YYYYY
spec:
behavior:
scaleDown:
policies:
- periodSeconds: 15
type: Pods
value: 1
selectPolicy: Min
stabilizationWindowSeconds: 60
scaleUp:
policies:
- periodSeconds: 15
type: Pods
value: 1
selectPolicy: Max
stabilizationWindowSeconds: 60
maxReplicas: 3
metrics:

  • resource:
    name: memory
    target:
    averageValue: 700Mi
    type: AverageValue
    type: Resource
    minReplicas: 1
    scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: XXXXX