metrics are specified, for example, then HPA evaluates each metric separately and proposes a value that is the largest of all. After all the calculations, the final output is a single integer number representing the number of desired replicas that keep the measured value below the desired threshold value. The  replicas  field of the autoscaled resource will be updated with this calculated number and other controllers do their bit of work in achieving and keeping the new desired state. Figure 24-1 shows how the HPA works: monitoring metrics and chang‐ ing declared replicas accordingly. Autoscaling is an area of Kubernetes with many low-level details that are still evolving rapidly, and each one can have a significant impact on the overall behavior of autoscaling. As such, it is beyond the scope of this book to cover all the details, but “More Information” on page 219 provides the latest up-to-date information on the subject. Broadly, there are the following metric types: Standard metrics These metrics are declared with  .spec.metrics.resource[:].type  equals to Resource  and represent resource usage metrics such as CPU and memory. They are generic and available for any container on any cluster under the same name. You can specify them as a percentage as we did in the preceding example, or as an absolute value. In both cases, the values are based on the guaranteed resource amount, which is the container resource  requests  values and not the  limits  val‐ ues. These are the easiest-to-use metric types generally provided by the metrics server or Heapster components, which can be launched as cluster addons. Custom metrics These metrics with  .spec.metrics.resource[&#x2a;].type  equals to  Object  or Pod  require a more advanced cluster monitoring setup, which can vary from cluster to cluster. A custom metric with the Pod type, as the name suggests, describes a Pod-specific metric, whereas the Object type can describe any other object. The custom metrics are served in an aggregated API Server under 208  |  Chapter 24: Elastic Scale Figure 24-1. Horizontal Pod autoscaling mechanism