Logo

dev-resources.site

for different kinds of informations.

Navigating Horizontal Pod Autoscaler (HPA) in Kubernetes

Published at
2/1/2024
Categories
kubernetes
hpa
autoscaler
pods
Author
mesrar
Categories
4 categories in total
kubernetes
open
hpa
open
autoscaler
open
pods
open
Author
6 person written this
mesrar
open
Navigating Horizontal Pod Autoscaler (HPA) in Kubernetes

The Horizontal Pod Autoscaler (HPA) in Kubernetes allows for automatic scaling of the number of pods in a deployment or replica set based on observed CPU utilization or other custom metrics. Let's explore essential commands for managing HPAs in your Kubernetes cluster.

Key Operations

View HPAs

To list all Horizontal Pod Autoscalers in the current namespace:

kubectl get hpa
Enter fullscreen mode Exit fullscreen mode

Delete an HPA
To delete a specific Horizontal Pod Autoscaler:

kubectl delete hpa <hpa-name>
Enter fullscreen mode Exit fullscreen mode

Create an HPA
Create an HPA for a deployment named "nginx" with minimum 5 and maximum 10 replicas, targeting 80% CPU utilization:

kubectl autoscale deploy nginx --min=5 --max=10 --cpu-percent=80
Enter fullscreen mode Exit fullscreen mode

This command sets up an HPA for the "nginx" deployment to automatically adjust the number of replicas based on CPU utilization, keeping it between 5 and 10 replicas and targeting 80% CPU usage.

Additional Insights
Desired Metrics: The HPA monitors the metrics defined (CPU utilization in this example) and adjusts the number of replicas to meet the specified targets.

Dynamic Scaling: HPA enables dynamic scaling based on real-time resource demand, ensuring optimal resource utilization.

Pod Metrics: HPAs can also be configured to scale based on custom metrics, such as memory usage, or external metrics like requests per second.

Scaling Behavior: The scaling behavior is defined by the --cpu-percent parameter, determining when to scale in or out based on the specified CPU utilization threshold.

Ensure that the configuration and metrics defined in your HPA align with the requirements and behavior of your application to achieve efficient and automated scaling.

Happy Autoscaling!

pods Article's
24 articles in total
Favicon
Exploring Kubernetes: A Step Ahead of Basics
Favicon
Understanding Kubernetes Pods and Controllers: ReplicaSets, Deployments, DaemonSets, and StatefulSets
Favicon
Understanding Kubernetes Pods with Docker: The Heart of Containerized Applications
Favicon
Understanding Kubernetes Basics: A Beginnerโ€™s Guide
Favicon
Gardening Overalls, Seeds, Pods, and Herbs
Favicon
Navigating Horizontal Pod Autoscaler (HPA) in Kubernetes
Favicon
Copying local file/directory to the k8s pod
Favicon
Kubernetes ConfigMaps and Secrets: A Developer's Guide
Favicon
SQS & Kubernetes Pods: The Quick and Dirty Guide to Read/Write Permissions
Favicon
Pod Disruption Budget in Kubernetes
Favicon
Kubernetes For Beginners : 3
Favicon
How to prevent data loss when a Postgres container is killed or shut down.
Favicon
Create You Own Pod
Favicon
Getting Started: Pod, Replicaset and Deployment in Kubernetes
Favicon
AKS Creation - Step by Step Approach
Favicon
Kubernetes - Part 1 - What are Pods in Kubernetes ?
Favicon
Understanding Kubernetes Evicted Pods
Favicon
Recommender algorithms for distributed social networks
Favicon
What is Kubernetes CrashLoopBackOff? And how to fix it
Favicon
How to restart Pods in Kubernetes : a complete guide
Favicon
K8s Pods: Image tags vs. Digest
Favicon
K8s Objects - Part 1 [Pods and Replicasets]
Favicon
React Native ํ”„๋กœ์ ํŠธ๋ฅผ git์— push ํ•˜๊ธฐ ์ „์— ํ•  ๊ฒƒ
Favicon
What are Kubernetes Pods Anyway?

Featured ones: