Now that we know how to add almost any metric to
HPAs, they are much more useful than what it seemed in the Autoscaling Deployments and StatefulSets Based On Resource Usage chapter. Initially,
HPAs weren’t very practical since memory and CPU are, in many cases, insufficient for making decisions on whether to scale our Pods. We had to learn how to collect metrics (we used
Prometheus Server for that), and how to instrument our applications to gain more detailed visibility. Custom Metrics was the missing piece of the puzzle. If we extend the “standard” metrics (CPU and memory) with the additional metrics we need (e.g.,
Prometheus Adapter), we gain a potent process that will keep the number of replicas of our applications in sync with internal and external demands. Assuming that our applications are scalable, we can guarantee that they will (almost) always be as performant as needed. There is no need for manual interventions any more, at least when scaling is in question.
HPA with “standard” and custom metrics will guarantee that the number of Pods meets the demand, and Cluster Autoscaler (when applicable) will ensure that we have the sufficient capacity to run those Pods.
Our system is one step closer to being self-sufficient. It will self-adapt to changed conditions, and we (humans) can turn our attention towards more creative and less repetitive tasks than those required to maintain the system in the state that meets the demand. We are one step closer to nirvana.