Skip to content

How to Create a Horizontal Pod Autoscaler in Kubernetes

If you could like to a create a Horizontal Pod Autoscaler (hpa) in Kubernetes, then you could run the following:

Step 1 – Create a Deployment

If you already have a deployment, then ignore this step, otherwise:

kubectl create deployment php-apache --image=us.gcr.io/k8s-artifacts-prod/hpa-example kubectl set resources deploy php-apache --requests=cpu=200m kubectl expose deploy php-apache --port 80 kubectl get pod -l app=php-apache
Code language: Bash (bash)

Step 2 – Create a Horizontal Pod Autoscaler

kubectl autoscale deployment php-apache `#The target average CPU utilization` \ --cpu-percent=50 \ --min=1 `#The lower limit for the number of pods that can be set by the autoscaler` \ --max=10 `#The upper limit for the number of pods that can be set by the autoscaler`
Code language: Bash (bash)

Step 3 – Get your hpa

kubectl get hpa
Code language: Bash (bash)

See also  Find All Numbers Disappeared in an Array using Python
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x