An HPA for the  random-generator  Deployment can be created with the command in Example 24-3. For the HPA to have any effect, it is important that the Deployment declare a  .spec.resources.requests  limit for the CPU as described in Chapter 2, Predictable Demands . Another requirement is that you have the metrics server enabled, which is a cluster-wide aggregator of resource usage data. The preceding command will create the HPA definition shown in Example 24-4. Minimum number of Pods that should always run Maximum number of Pods until the HPA can scale up Reference to the object that should be associated with this HPA Desired CPU usage as a percentage of the Pods, requested CPU resource. For example, when the Pods have a  .spec.resources.requests.cpu  of 200m, a scale-up happens when on average more than 100m CPU (= 50%) is utilized. Example 24-3. Create HPA definition on the command line Example 24-4. HPA definition apiVersion : autoscaling/v2beta2 kind : HorizontalPodAutoscaler metadata : name : random-generator spec : minReplicas : 1 maxReplicas : 5 scaleTargetRef : apiVersion : extensions/v1beta1 kind : Deployment name : random-generator metrics : -  resource : name : cpu target : averageUtilization : 50 type : Utilization type : Resource kubectl autoscale deployment random-generator --cpu-percent=50 --min=1 --max=5 206  |  Chapter 24: Elastic Scale