Configure Kubernetes Horizontal Pod Autoscaler
Enable metrics plugin on Minikube
Start a deployment and expose it as a service
Create Horizontal Pod Autoscaler
This command creates an HPA with a minimum of one pod and maximum of ten pods running. It will try to keep the averga usage of the pods at 50% and if there is more usage, it will automatically create more pods to keep the usage at 50%.
To test it, run the following on a different terminal
Then, to create the trafic neede for the HPA start working.
Back on the first terminal, monitor the HPA with
To have more control over the HPA we can also create it with a mainfest file, the equivalent to the command kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10
would be:
HPA can also be configured depending on the cpu usage or requests recieved, it is a good idea save it as a file to keeep record of the configuration for the HPA.
Reference Links
Last updated