Kubernetes Horizontal Pod Autoscaler Not Scaling Down After Load Reduction on v1.28
I'm migrating some code and I'm wondering if anyone has experience with I've been working on this all day and I'm experiencing an scenario with the Horizontal Pod Autoscaler (HPA) in my Kubernetes cluster not scaling down the number of pods after a important load reduction. The HPA was configured to manage a deployment running a Node.js application, and I set the target CPU utilization to 50%. After a traffic spike, the HPA scaled up from 2 to 6 pods, which worked as expected. However, after the load decreased, the HPA did not scale down, and the pods remained at 6 even though CPU utilization dropped to around 20%. Hereβs the HPA configuration I used: ```yaml apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: AverageUtilization averageUtilization: 50 ``` Iβve also confirmed that the metrics server is running and providing metrics as expected using: ```bash kubectl get --raw /apis/metrics.k8s.io/v1beta1/pods | jq '.' ``` The output shows the CPU metrics for all pods in the deployment, and they seem accurate. I also checked the HPA events with: ```bash kubectl describe hpa my-app-hpa ``` The events indicate that scaling actions were taken, but it seems the HPA is exploring at 6 replicas despite the low CPU utilization. I tried tweaking the `averageUtilization` target and even increased the `minReplicas` to see if it would trigger a scale-down, but nothing changed. Iβm running Kubernetes v1.28, and I wonder if there are any specific settings or considerations I might have missed that could affect the scaling behavior. Has anyone else encountered this scenario, or can you suggest potential fixes or debugging steps? I've been using Yaml for about a year now. Any advice would be much appreciated. This is my first time working with Yaml LTS. Am I approaching this the right way? What am I doing wrong? I'm working on a REST API that needs to handle this. I'm open to any suggestions. My team is using Yaml for this desktop app.