I've got my HPA like this. The pods are scaling well but its not scaling down and the CPU utilization is just 5%. It is not scaling down to the minimum of 1 replica.
The below is my HPA
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: app
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: app
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: 100Mi
In the above yaml file, I was using two resources as shown below
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: 100Mi
The memory resource was not quickly released by the application and once I removed the memory resource the pods scaled down when the utilization was less.