Kubernetes Horizontal Pod Autoscaler: Difference between revisions
Line 22: | Line 22: | ||
==<span id='HorizontalPodAutoscaler_Controller'></span>Horizontal Pod Autoscaler Controller== | ==<span id='HorizontalPodAutoscaler_Controller'></span>Horizontal Pod Autoscaler Controller== | ||
The horizontal pod autoscaler controller is part of the cluster's [[Kubernetes_Control_Plane_and_Data_Plane_Concepts#Controller_Manager|controller manager]] process. | The horizontal pod autoscaler controller is part of the cluster's [[Kubernetes_Control_Plane_and_Data_Plane_Concepts#Controller_Manager|controller manager]] process. | ||
===Autoscaling Algorithm=== | |||
==<span id='HorizontalPodAutoscaler_Resource'></span>Horizontal Pod Autoscaler Resource== | ==<span id='HorizontalPodAutoscaler_Resource'></span>Horizontal Pod Autoscaler Resource== |
Revision as of 20:42, 9 October 2020
External
- https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
- https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
- https://towardsdatascience.com/kubernetes-hpa-with-custom-metrics-from-prometheus-9ffc201991e
- https://github.com/kubernetes/community/blob/master/contributors/design-proposals/instrumentation/custom-metrics-api.md
Internal
Overview
Horizontal pod autoscaling is the automatic increase or decrease the number of pod replicas managed by a higher level controller that supports scaling, such as deployments, replica sets and stateful sets.
How it Works
The scaling is performed by a horizontal pod controller and it is controlled by a HorizontalPodAutoscaler Kubernetes API resource, which enables and configures the horizontal pod autoscaler. For an horizontal pod autoscaler to work correctly, a source of metrics, in particular resource metrics, must be deployed. The simplest source of resource metrics is the metrics server.
The controller periodically reads the appropriate metrics API to obtain metrics for the pods it monitors. The set of pods to watch is provided by the higher level pod controller the autoscaler is associated with. The autoscaler calculates the number of replicas required to meet the target metric configured on the HorizontalPodAutoscaler resource. If there is a mismatch, the controller adjusts the "replicas" field on the target pod controller. The target pod controller is not aware of the autoscaler. In what it is concerned, anybody, including the autoscaler, may update the replica count.
Horizontal Pod Autoscaler Controller
The horizontal pod autoscaler controller is part of the cluster's controller manager process.
Autoscaling Algorithm
Horizontal Pod Autoscaler Resource
The HorizontalPodAutoscaler Kubernetes API resource is deployed as any other Kubernetes resource by posting a manifest to the API server.