Kubernetes Horizontal Pod Autoscaler: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 18: Line 18:
{{Internal|Kubernetes Horizontal Pod Autoscaler Manifest|Horizontal Pod Autoscaler Manifest}}
{{Internal|Kubernetes Horizontal Pod Autoscaler Manifest|Horizontal Pod Autoscaler Manifest}}
=How it Works=
=How it Works=
The scaling is performed by a [[#HorizontalPodAutoscaler_Controller|horizontal pod controller]] and it is controlled by a [[#HorizontalPodAutoscaler_Resource|horizontal pod autoscaler Kubernetes API resource]]. For an horizontal pod autoscaler to work correctly, a source of metrics, in particular [[Metrics_in_Kubernetes#Resource_Metrics|resource metrics]], must be deployed. The simplest source of resource metrics is the [[Kubernetes Metrics Server|metrics server]].
The scaling is performed by a [[#HorizontalPodAutoscaler_Controller|horizontal pod controller]] and it is controlled by a [[#HorizontalPodAutoscaler_Resource|horizontal pod autoscaler Kubernetes API resource]]. For an horizontal pod autoscaler to work correctly, a source of metrics, in particular [[Metrics_in_Kubernetes#Resource_Metrics|resource metrics]], must be deployed. The simplest source of resource metrics is the [[Kubernetes Metrics Server|metrics server]]. A HorizontalPodAutoscaler [[#HorizontalPodAutoscaler_Resource|Kubernetes API resource]] enables and configures the [[#HorizontalPodAutoscaler_Controller|horizontal pod controller]]. The controller periodically reads the appropriate [[Metrics_in_Kubernetes#Metrics|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.
 
A HorizontalPodAutoscaler [[#HorizontalPodAutoscaler_Resource|Kubernetes API resource]] enables and configures the [[#HorizontalPodAutoscaler_Controller|horizontal pod controller]]. The controller periodically reads the appropriate [[Metrics_in_Kubernetes#Metrics|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.
The target pod controller is not aware of the autoscaler. In what it is concerned, anybody, including the autoscaler, may update the replica count.

Revision as of 19:45, 9 October 2020

External

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

https://github.com/ovidiuf/playground/tree/master/kubernetes/horizontal-pod-autoscaler

HPA Manifest

Horizontal Pod Autoscaler 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 is part of the cluster's controller manager process.

Horizontal Pod Autoscaler Resource

The HorizontalPodAutoscaler Kubernetes API resource is deployed as any other Kubernetes resource by posting a manifest to the API server.

Metrics and Autoscaling.png

Operations