This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.此内容没有您所选择的语言版本。
Chapter 18. Pod Autoscaling
18.1. 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.
Horizontal pod autoscaling is supported starting in OpenShift Enterprise 3.1.1.
18.2. Requirements for Using Horizontal Pod Autoscalers 复制链接链接已复制到粘贴板!
In order to use horizontal pod autoscalers, your cluster administrator must have properly configured cluster metrics.
18.3. Supported Metrics 复制链接链接已复制到粘贴板!
The following metrics are supported by horizontal pod autoscalers:
Metric | Description |
---|---|
CPU Utilization | Percentage of the requested CPU |
18.4. Autoscaling 复制链接链接已复制到粘贴板!
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.
18.5. Creating a Horizontal Pod Autoscaler 复制链接链接已复制到粘贴板!
To create a horizontal pod autoscaler, first define it in a file. For example:
Example 18.1. Horizontal Pod Autoscaler Object Definition
- 1
- The name of this horizontal pod autoscaler object
- 2
- The kind of object to scale
- 3
- The name of the object to scale
- 4
- The API version of the object to scale
- 5
- The minimum number of replicas to which to scale down
- 6
- The maximum number of replicas to which to scale up
- 7
- The percentage of the requested CPU that each pod should ideally be using
Save your definition to a file, such as scaler.yaml, then use the CLI to create the object:
oc create -f scaler.yaml
$ oc create -f scaler.yaml
18.6. Viewing a Horizontal Pod Autoscaler 复制链接链接已复制到粘贴板!
To view the status of a horizontal pod autoscaler: