Overview

A horizontal pod autoscaler, defined by a HorizontalPodAutoscaler object,
specifies how the system should automatically increase or decrease the scale of
a replication controller or deployment configuration, based on metrics collected
from the pods that belong to that replication controller or deployment
configuration.

Autoscaling

You can create a horizontal pod autoscaler with the oc autoscale command and
specify the minimum and maximum number of pods you want to run, as well as the
CPU utilization or memory utilization your pods should target.

Autoscaling for Memory Utilization is a Technology Preview feature only.

After a horizontal pod autoscaler is created, it begins attempting to query
Heapster for metrics on the pods. It may take one to two minutes before Heapster
obtains the initial metrics.

After metrics are available in Heapster, the horizontal pod autoscaler computes
the ratio of the current metric utilization with the desired metric utilization,
and scales up or down accordingly. The scaling will occur at a regular interval,
but it may take one to two minutes before metrics make their way into Heapster.

For replication controllers, this scaling corresponds directly to the replicas
of the replication controller. For deployment configurations, scaling corresponds
directly to the replica count of the deployment configuration. Note that autoscaling
applies only to the latest deployment in the Complete phase.

OpenShift Container Platform automatically accounts for resources and prevents unnecessary autoscaling
during resource spikes, such as during start up. Pods in the unready state
have 0 CPU usage when scaling up and the autoscaler ignores the pods when scaling down.
Pods without known metrics have 0% CPU usage when scaling up and 100% CPU when scaling down.
This allows for more stability during the HPA decision. To use this feature, you must configure
readiness
checks to determine if a new pod is ready for use.

Autoscaling for CPU Utilization

Use the oc autoscale command and specify at least the maximum number of pods
you want to run at any given time. You can optionally specify the minimum number
of pods and the average CPU utilization your pods should target, otherwise those
are given default values from the OpenShift Container Platform server.

The average percentage of the requested CPU that each pod should be using

Autoscaling for Memory Utilization

Autoscaling for Memory Utilization is a Technology Preview feature only.
Technology Preview features are not supported with Red Hat production service
level agreements (SLAs), might not be functionally complete, and Red Hat does
not recommend to use them for production. These features provide early access to
upcoming product features, enabling customers to test functionality and provide
feedback during the development process.

Unlike CPU-based autoscaling, memory-based autoscaling requires specifying the
autoscaler using YAML instead of using the oc autoscale command. Optionally,
you can specify the minimum number of pods and the average memory utilization
your pods should target as well, otherwise those are given default values from
the OpenShift Container Platform server.

Memory-based autoscaling is only available with the v2beta1 version of the
autoscaling API. Enable memory-based autoscaling by adding the following to your
cluster’s master-config.yaml file:

The AbleToScale condition indicates whether HPA is able to fetch and update scales, as well as whether any backoff-related conditions would prevent scaling.

The ScalingActive condition indicates whether the HPA is enabled (for example, the replica count of the target is not zero) and is able to calculate desired scales. A`False` status generally indicates problems with fetching metrics.

The ScalingLimited condition indicates that the desired scale was capped by the maximum or minimum of the horizontal pod autoscaler. A True status generally indicates that you might need to raise or lower the minimum or maximum replica count constraints on your horizontal pod autoscaler.

The following is an example of a pod that could not obtain the needed metrics for scaling:

Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True SucceededGetScale the HPA controller was able to get the target's current scale
ScalingActive False FailedGetResourceMetric the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from heapster

The following is an example of a pod where the requested autoscaling was less than the required minimums:

Conditions:
Type Status Reason Message
---- ------ ------ -------
AbleToScale True ReadyForNewScale the last scale time was sufficiently old as to warrant a new scale
ScalingActive True ValidMetricFound the HPA was able to successfully calculate a replica count from pods metric http_request
ScalingLimited False DesiredWithinRange the desired replica count is within the acceptable range
Events: