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
- type: Pods