Setting A Deployment's Replicas And Having A Horizontal Pod Autoscaler

What happens if you set a Kubernetes deployment’s number of desired replicas and have a horizontal pod autoscaler (HPA) for the same deployment?

The short answer is the HPA takes precedence.

The HPA will override the Deployment’s replica count based on the observed metrics and the scaling rules defined in the HPA configuration.

Even if you manually change the replica count in the Deployment, the HPA will eventually adjust it to match the desired target utilization.

Don’t manually modify the deployment’s replica count in the deployment if there’s an HPA controlling it because it can lead to conflicts and strange behavior.

Join the 80/20 DevOps Newsletter

If you're an engineering leader or developer, you should subscribe to my 80/20 DevOps Newsletter. Give me 1 minute of your day, and I'll teach you essential DevOps skills. I cover topics like Kubernetes, AWS, Infrastructure as Code, and more.

Not sure yet? Check out the archive.

Unsubscribe at any time.