Kubernetes Horizontal Pod Autoscaler: Difference between revisions
Line 24: | Line 24: | ||
The target pod controller is not aware of the autoscaler. In what it is concerned, anybody, including the autoscaler, may update the replica count. | The target pod controller is not aware of the autoscaler. In what it is concerned, anybody, including the autoscaler, may update the replica count. | ||
== | ==<span id='HorizontalPodAutoscaler_Controller'></span>Horizontal Pod Autoscaler Controller== | ||
The horizontal pod autoscaler controller runs in the cluster's [[Kubernetes_Control_Plane_and_Data_Plane_Concepts#Controller_Manager|controller manager]] process. The controller manager process is usually named kube-controller-manager, and exists either as a pod in the "kube-system" namespace or a process on one of the control plane nodes. | The horizontal pod autoscaler controller runs in the cluster's [[Kubernetes_Control_Plane_and_Data_Plane_Concepts#Controller_Manager|controller manager]] process. The controller manager process is usually named kube-controller-manager, and exists either as a pod in the "kube-system" namespace or a process on one of the control plane nodes. | ||
Revision as of 03:29, 7 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.
Playground
HPA Manifest
How it Works
The scaling is performed by a horizontal pod controller and it is controlled by a horizontal pod autoscaler Kubernetes API resource. 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.
A HorizontalPodAutoscaler Kubernetes API resource enables and configures the horizontal pod controller. The controller periodically reads the appropriate metrics API, calculates the number of replicas required to meet the target metric value configured in the HorizontalPodAutoscaler resource, and adjust 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 runs in the cluster's controller manager process. The controller manager process is usually named kube-controller-manager, and exists either as a pod in the "kube-system" namespace or a process on one of the control plane nodes.
HorizontalPodAutoscaler Resource
The HorizontalPodAutoscaler Kubernetes API resource is deployed as any other Kubernetes resource by posting a manifest to the API server.