Thursday, February 29, 2024
HomeSoftware EngineeringHow you can Create a Horizontal Pod Autoscaler in Kubernetes

How you can Create a Horizontal Pod Autoscaler in Kubernetes


In the event you may wish to a create a Horizontal Pod Autoscaler (hpa) in Kubernetes, then you might run the next:

Step 1 – Create a Deployment

If you have already got a deployment, then ignore this step, in any other case:

kubectl create deployment php-apache --image=us.gcr.io/k8s-artifacts-prod/hpa-example
kubectl set sources deploy php-apache --requests=cpu=200m
kubectl expose deploy php-apache --port 80

kubectl get pod -l app=php-apache

Step 2 – Create a Horizontal Pod Autoscaler

kubectl autoscale deployment php-apache `#The goal common CPU utilization` 
    --cpu-percent=50 
    --min=1 `#The decrease restrict for the variety of pods that may be set by the autoscaler` 
    --max=10 `#The higher restrict for the variety of pods that may be set by the autoscaler`

Step 3 – Get your hpa

kubectl get hpa
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments