How you can Create a Horizontal Pod Autoscaler in Kubernetes

0
8
Adv1


Adv2

In case you might wish to a create a Horizontal Pod Autoscaler (hpa) in Kubernetes, then you possibly can 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
Adv3