Appinventiv Call Button

Kubernetes Horizontal Pod Autoscaling – What is it and how does it work?

Sudeep Srivastava
Director & Co-Founder
July 18, 2025
Kubernetes Horizontal Pod Autoscaling
copied!

Autoscaling is one of the prominent features of the Kubernetes cluster. Once configured correctly, it saves administrators’ time, prevents performance bottlenecks, and helps avoid financial waste. It is a feature wherein the cluster can increase the number of pods as the demand for service response increases and decrease the number of pods as the requirement decreases.

One of the ways in which Kubernetes enables autoscaling is through Horizontal Pod Autoscaling. HPA can help applications scale out to meet increased demand or scale in when resources are no longer needed. This type of autoscaling does not apply to objects that can’t be scaled.

In this article, we will take a deep dive into the topic of Horizontal Pod Autoscaling in Kubernetes. We’ll define HPA, explain how it works, and provide a detailed tutorial to configure HPA. But before that, let’s first understand what is Kubernetes.

So, without further ado, let’s get started!

What is Kubernetes?

Kubernetes is an open-source container management tool that automates container deployment, container scaling, and load balancing. It schedules, runs, and manages isolated containers running on virtual, physical, and cloud machines.

Kubernetes Horizontal Pod Autoscaling (HPA) :

The Kubernetes Horizontal Pod Autoscaling automatically scales the number of pods in a replication controller, deployment, or replica set based on that resource’s CPU utilization.

Kubernetes has the possibility to automatically scale pods based on observed CPU utilization which is horizontal pod autoscaling. Scaling can be done only for scalable objects like controller, deployment, or replica sets. HPA is implemented as a Kubernetes Application Programming Interface (API) resource and a controller.

With the controller, one can periodically adjust the number of replicas in a deployment or replication controller to match the observed average CPU utilization to the target specified by the user.

HPA Autoscaling

How does a Horizontal PodAutoscaler work?

In simpler words, HPA works in a ‘check, update, check again’ style loop. Here’s how each of the steps in that loop work:

1. Horizontal Pod Autscaler keeps monitoring the metrics server for resource usage.

2. HPA will calculate the required number of replicas on the basis of collected resource usage.

3. Then, HPA decides to scale up the application to the number of replicas required.

4. After that, HPA will change the desired number of replicas.

5. Since HPA is monitoring on a continous basis, the process repeats from Step 1.

How does a Horizontal PodAutoscaler work?

Configuring Horizontal Pod AutoScaling

Let’s create a simple deployment :-

kind: Deployment                      #Defines to create deployment type Object apiVersion: apps/v1
metadata: name: mydeploy         #deployment name
spec:
replicas: 2                                        #define number of pods you want
selector:              #Apply this deployment to any pods which has the specific label
matchLabels:
name:deployment
template:
metadata:
name: testpod8            #pod name
labels:
name: deployment
spec:
containers: -
name: c00                    #container name
Image: httpd
ports:
- containerPort: 80         #Containers port exposed
resources:
limits:
cpu: 500m
requests:
cpu: 200m

Now, create autoscaling 

  • kubectl autoscale deployment mydeploy –cpu-percent=20 –min=1 –max=10

Let’s check the HPA entries.

  • kubectl get hpa

Talk to our experts

Final thoughts

We hope this blog was helpful in understanding how Kubernetes Horizontal Pod Autoscaling works and how it can be configured. HPA allows you to scale your applications based on different metrics. By scaling to the correct number of pods dynamically, you can utilize the application in a performant and cost-efficient manner.

If you require further assistance with Horizontal Pod Autoscaling or wish to explore it in greater detail, consider reaching out to a trusted cloud technology consulting partner like Appinventiv.

THE AUTHOR
Sudeep Srivastava
Director & Co-Founder

With over 15 years of experience at the forefront of digital transformation, Sudeep Srivastava is the Co-founder and Director of Appinventiv. His expertise spans AI, Cloud, DevOps, Data Science, and Business Intelligence, where he blends strategic vision with deep technical knowledge to architect scalable and secure software solutions. A trusted advisor to the C-suite, Sudeep guides industry leaders on using IT consulting and custom software development to navigate market evolution and achieve their business goals.

Prev PostNext Post
Let's Build Digital Excellence Together
Let's Build Digital Excellence Together
  • In just 2 mins you will get a response
  • Your idea is 100% protected by our Non Disclosure Agreement.
Read More Blogs
cloud migration ROI

How to evaluate the ROI and cost-benefit of cloud migration

Key takeaways: A proper cloud migration cost estimation must factor in hidden expenses like employee retraining, potential downtime, and integration challenges. Faster time-to-market, boosted innovation with AI/ML tools, and improved business agility become critical pieces of your cloud migration cost-benefit analysis. Assessing cloud migration ROI means setting a clear baseline of your current costs and…

Sudeep Srivastava
best cloud solution for business

Which Is the Best Cloud Solution for Your Business - Public, Private, Hybrid, or Multi-Cloud?

Key Takeaways There’s no one-size-fits-all: The best cloud solution for your business depends on your unique priorities, that is, speed, cost, compliance, and growth stage. Public, private, hybrid, and multi-cloud models each offer distinct trade-offs in control, risk, scalability, and cost structure. For startups, public cloud offers speed and agility, while enterprises often benefit from…

Sudeep Srivastava
Kubernetes Cost Optimization with Karpenter and Spot Instances

Kubernetes Cost Optimization with Karpenter and Spot Instances: A Customer Success Story

In today’s cloud-first enterprise environment, organizations are adopting Kubernetes to power modern applications at scale. While Kubernetes brings agility, running clusters on cloud infrastructure often results in rapidly increasing compute costs. Striking the balance between performance, scalability, and cost efficiency is a common challenge. In this blog, we highlight a real-world customer success story where…

Sudeep Srivastava
Mobile App Consulting Company on Clutch Most trusted Mobile App Consulting Company on Clutch
appinventiv India
INDIA

B-25, Sector 58,
Noida- 201301,
Delhi - NCR, India

appinventiv USA
USA

79, Madison Ave
Manhattan, NY 10001,
USA

appinventiv Australia
Australia

96 Cleveland Street,
Stones Corner,
QLD 4120

appinventiv London UK
UK

3rd Floor, 86-90
Paul Street EC2A 4NE
London, UK

appinventiv UAE
UAE

Tiger Al Yarmook Building,
13th floor B-block
Al Nahda St - Sharjah

appinventiv Canada
CANADA

Suite 3810, Bankers Hall West,
888 - 3rd Street Sw
Calgary Alberta