Below is a Yaml file representing a deployment for twonginx pod replicas, with defined resource limits and requests:
A container can use more than the requested CPU, but it can't go beyond the set limit.
The below command runs the Autoscaler on the deployment "nginx-dep":
The Autoscaler will add or remove pods - number of pods will be between "2" and "10" pods at all times-, while maintaining a CPU consumption of "50%" of CPU resources, as stated above in the "--cpu-percent" parameter.
We solicit the nginx pods -by sending them requests-then, we check the Autoscaler output parameter "TARGET = 50% (half) out of the 50% is used":
Now, we could check our deployment, using the below command:
We see that the deployment is running three pods now - it added one pod -.
The Yaml file of our Autoscaler will look like the below: