Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/nodes-pods-autoscaling-about.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-about_{context}"]
= Understanding horizontal pod autoscalers

You can create a horizontal pod autoscaler to specify the minimum and maximum number of pods you want to run, and the CPU usage or memory usage your pods should target.
[role="_abstract"]
You can create a horizontal pod autoscaler to specify the minimum and maximum number of pods you want to run and the CPU usage or memory usage your pods should target.

After you create a horizontal pod autoscaler, {product-title} begins to query the CPU, memory, or both resource metrics on the pods. When these metrics are available, the horizontal pod autoscaler computes the ratio of the current metric use with the intended metric use, and scales up or down as needed. The query and scaling occurs at a regular interval, but can take one to two minutes before metrics become available.

Expand Down
3 changes: 2 additions & 1 deletion modules/nodes-pods-autoscaling-best-practices-hpa.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-best-practices-hpa_{context}"]
= Best practices

For optimal performance, configure resource requests for all pods. To prevent frequent replica fluctuations, configure the cooldown period.
[role="_abstract"]
You can help ensure optimal performance in your cluster by configuring resource requests for all pods. Additionally, you can prevent frequent replica fluctuations by configuring the cooldown period.

All pods must have resource requests configured::
The HPA makes a scaling decision based on the observed CPU or memory usage values of pods in an {product-title} cluster. Utilization values are calculated as a percentage of the resource requests of each pod. Missing resource request values can affect the optimal performance of the HPA.
Expand Down
22 changes: 13 additions & 9 deletions modules/nodes-pods-autoscaling-creating-cpu-percent.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-creating-cpu-percent_{context}"]
= Creating a horizontal pod autoscaler for a percent of CPU use

Using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing object based on percent of CPU use. The HPA scales the pods associated with that object to maintain the CPU use that you specify.
[role="_abstract"]
You can use the {product-title} CLI to create a horizontal pod autoscaler (HPA) that automatically scales an existing object based on percent of CPU use. The HPA scales the pods associated with that object to maintain the CPU use that you specify.

When autoscaling for a percent of CPU use, you can use the `oc autoscale` command to specify the minimum and maximum number of pods that you want to run at any given time and the average CPU use your pods should target. If you do not specify a minimum, the pods are given default values from the {product-title} server.

Expand All @@ -25,16 +26,19 @@ include::snippets/nodes-pods-autoscaling-creating-cpu-prereqs.adoc[]
+
[source,terminal]
----
$ oc autoscale <object_type>/<name> \// <1>
--min <number> \// <2>
--max <number> \// <3>
--cpu-percent=<percent> <4>
$ oc autoscale <object_type>/<name> \
--min <number> \
--max <number> \
--cpu-percent=<percent>
----
where:
+
<1> Specify the type and name of the object to autoscale. The object must exist and be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
<2> Optional: Specify the minimum number of replicas when scaling down.
<3> Specify the maximum number of replicas when scaling up.
<4> Specify the target average CPU use over all the pods, represented as a percent of requested CPU. If not specified or negative, a default autoscaling policy is used.
--
`<object_type>/<name>`:: Specifies the type and name of the object to autoscale. The object must exist and be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
`min`:: Specifies the minimum number of replicas when scaling down. Replace `<number>` with the minimum number of replicas. This parameter is optional.
`max`:: Specifies the maximum number of replicas when scaling up. Replace `<number>` with the maximum number of replicas.
`cpu-percent`:: Specifies the target average CPU use over all the pods, represented as a percent of requested CPU. Replace `<percent>` with requested percentage. If not specified or negative, a default autoscaling policy is used.
--
+
For example, the following command shows autoscaling for the `hello-node` deployment object. The initial deployment requires 3 pods. The HPA object increases the minimum to 5. If CPU usage on the pods reaches 75%, the pods will increase to 7:
+
Expand Down
51 changes: 28 additions & 23 deletions modules/nodes-pods-autoscaling-creating-cpu-specific.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-creating-cpu-specific_{context}"]
= Creating a horizontal pod autoscaler for a specific CPU value

Using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing object based on a specific CPU value by creating a `HorizontalPodAutoscaler` object with the target CPU and pod limits. The HPA scales the pods associated with that object to maintain the CPU use that you specify.
[role="_abstract"]
You can use the {product-title} CLI to create a horizontal pod autoscaler (HPA) that automatically scales an existing object based on a specific CPU value by creating a `HorizontalPodAutoscaler` object with the target CPU and pod limits. The HPA scales the pods associated with that object to maintain the CPU use that you specify.

[NOTE]
====
Expand All @@ -23,40 +24,44 @@ include::snippets/nodes-pods-autoscaling-creating-cpu-prereqs.adoc[]
+
[source,yaml,options="nowrap"]
----
apiVersion: autoscaling/v2 <1>
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: cpu-autoscale <2>
name: cpu-autoscale
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1 <3>
kind: Deployment <4>
name: example <5>
minReplicas: 1 <6>
maxReplicas: 10 <7>
metrics: <8>
apiVersion: apps/v1
kind: Deployment
name: example
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu <9>
name: cpu
target:
type: AverageValue <10>
averageValue: 500m <11>
type: AverageValue
averageValue: 500m
----
<1> Use the `autoscaling/v2` API.
<2> Specify a name for this horizontal pod autoscaler object.
<3> Specify the API version of the object to scale:
where:
+
--
`apiVersion`:: Specifies the `autoscaling/v2` API.
`metadata.name`:: Specifies a name for this horizontal pod autoscaler object.
`spec.scaleTargetRef.apiVersion`:: Specifies the API version of the object to scale:
* For a `Deployment`, `ReplicaSet`, `Statefulset` object, use `apps/v1`.
* For a `ReplicationController`, use `v1`.
* For a `DeploymentConfig`, use `apps.openshift.io/v1`.
<4> Specify the type of object. The object must be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
<5> Specify the name of the object to scale. The object must exist.
<6> Specify the minimum number of replicas when scaling down.
<7> Specify the maximum number of replicas when scaling up.
<8> Use the `metrics` parameter for memory use.
<9> Specify `cpu` for CPU usage.
<10> Set to `AverageValue`.
<11> Set to `averageValue` with the targeted CPU value.
`spec.scaleTargetRef.kind`:: Specifies the type of object. The object must be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
`spec.scaleTargetRef.name`:: Specifies the name of the object to scale. The object must exist.
`spec.minReplicas`:: Specifies the minimum number of replicas when scaling down.
`spec.maxReplicas`:: Specifies the maximum number of replicas when scaling up.
`spec.metrics`:: Specifies the parameters to calculate the desired replica count.
`spec.metrics.resource.name`:: Specifies a name for the resource.
`spec.metrics.resource.target.type`:: Specifies the type of target, here `AverageValue` for a specific CPU value.
`spec.metrics.resource.target.averageValue`:: Specifies the targeted CPU value.
--

. Create the horizontal pod autoscaler:
+
Expand Down
5 changes: 3 additions & 2 deletions modules/nodes-pods-autoscaling-creating-cpu.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
//
// * nodes/nodes-pods-autoscaling.adoc

:_mod-docs-content-type: PROCEDURE
:_mod-docs-content-type: CONCEPT
[id="nodes-pods-autoscaling-creating-cpu_{context}"]
= Creating a horizontal pod autoscaler by using the CLI

Using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing `Deployment`, `DeploymentConfig`, `ReplicaSet`, `ReplicationController`, or `StatefulSet` object. The HPA scales the pods associated with that object to maintain the CPU or memory resources that you specify.
[role="_abstract"]
By using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing `Deployment`, `DeploymentConfig`, `ReplicaSet`, `ReplicationController`, or `StatefulSet` object. The HPA scales the pods associated with that object to maintain the CPU or memory resources that you specify.

You can autoscale based on CPU or memory use by specifying a percentage of resource usage or a specific value, as described in the following sections.

Expand Down
62 changes: 33 additions & 29 deletions modules/nodes-pods-autoscaling-creating-memory-percent.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

= Creating a horizontal pod autoscaler object for a percent of memory use

Using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing object based on a percent of memory use. The HPA scales the pods associated with that object to maintain the memory use that you specify.
[role="_abstract"]
You can use the {product-title} CLI to create a horizontal pod autoscaler (HPA) that automatically scales an existing object based on a percent of memory use. The HPA scales the pods associated with that object to maintain the memory use that you specify.

[NOTE]
====
Expand All @@ -26,26 +27,26 @@ include::snippets/nodes-pods-autoscaling-creating-cpu-prereqs.adoc[]
+
[source,yaml,options="nowrap"]
----
apiVersion: autoscaling/v2 <1>
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: memory-autoscale <2>
name: memory-autoscale
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1 <3>
kind: Deployment <4>
name: example <5>
minReplicas: 1 <6>
maxReplicas: 10 <7>
metrics: <8>
apiVersion: apps/v1
kind: Deployment
name: example
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: memory <9>
name: memory
target:
type: Utilization <10>
averageUtilization: 50 <11>
behavior: <12>
type: Utilization
averageUtilization: 50
behavior:
scaleUp:
stabilizationWindowSeconds: 180
policies:
Expand All @@ -57,23 +58,26 @@ spec:
periodSeconds: 120
selectPolicy: Max
----
<1> Use the `autoscaling/v2` API.
<2> Specify a name for this horizontal pod autoscaler object.
<3> Specify the API version of the object to scale:
* For a ReplicationController, use `v1`.
* For a DeploymentConfig, use `apps.openshift.io/v1`.
* For a Deployment, ReplicaSet, Statefulset object, use `apps/v1`.
<4> Specify the type of object. The object must be a `Deployment`, `DeploymentConfig`,
`ReplicaSet`, `ReplicationController`, or `StatefulSet`.
<5> Specify the name of the object to scale. The object must exist.
<6> Specify the minimum number of replicas when scaling down.
<7> Specify the maximum number of replicas when scaling up.
<8> Use the `metrics` parameter for memory usage.
<9> Specify `memory` for memory usage.
<10> Set to `Utilization`.
<11> Specify `averageUtilization` and a target average memory usage over all the pods,
where:
+
--
`apiVersion`:: Specifies the `autoscaling/v2` API.
`metadata.name`:: Specifies a name for this horizontal pod autoscaler object.
`spec.scaleTargetRef.apiVersion`:: Specifies the API version of the object to scale:
* For a `Deployment`, `ReplicaSet`, `Statefulset` object, use `apps/v1`.
* For a `ReplicationController`, use `v1`.
* For a `DeploymentConfig`, use `apps.openshift.io/v1`.
`spec.scaleTargetRef.kind`:: Specifies the type of object. The object must be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
`spec.scaleTargetRef.name`:: Specifies the name of the object to scale. The object must exist.
`spec.minReplicas`:: Specifies the minimum number of replicas when scaling down.
`spec.maxReplicas`:: Specifies the maximum number of replicas when scaling up.
`spec.metrics`:: Specifies the parameters to calculate the desired replica count.
`spec.metrics.resource.name`:: Specifies a name for the resource.
`spec.metrics.resource.target.type`:: Specifies the type of target, here `Utilization` for a percentage value.
`spec.metrics.resource.target.averageUtilization`:: Specifies the targeted average memory usage over all the pods,
represented as a percent of requested memory. The target pods must have memory requests configured.
<12> Optional: Specify a scaling policy to control the rate of scaling up or down.
`spec.behavior`:: Optional: Specifies a scaling policy to control the rate of scaling up or down.
--

. Create the horizontal pod autoscaler by using a command similar to the following:
+
Expand Down
58 changes: 31 additions & 27 deletions modules/nodes-pods-autoscaling-creating-memory-specific.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

= Creating a horizontal pod autoscaler object for specific memory use

Using the {product-title} CLI, you can create a horizontal pod autoscaler (HPA) to automatically scale an existing object. The HPA scales the pods associated with that object to maintain the average memory use that you specify.
[role="_abstract"]
You can use the {product-title} CLI to create a horizontal pod autoscaler (HPA) that automatically scales an existing object. The HPA scales the pods associated with that object to maintain the average memory use that you specify.

[NOTE]
====
Expand All @@ -26,26 +27,26 @@ include::snippets/nodes-pods-autoscaling-creating-cpu-prereqs.adoc[]
+
[source,yaml,options="nowrap"]
----
apiVersion: autoscaling/v2 <1>
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: hpa-resource-metrics-memory <2>
name: hpa-resource-metrics-memory
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1 <3>
kind: Deployment <4>
name: example <5>
minReplicas: 1 <6>
maxReplicas: 10 <7>
metrics: <8>
apiVersion: apps/v1
kind: Deployment
name: example
minReplicas: 1
maxReplicas: 10
metrics:
- type: Resource
resource:
name: memory <9>
name: memory
target:
type: AverageValue <10>
averageValue: 500Mi <11>
behavior: <12>
type: AverageValue
averageValue: 500Mi
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
Expand All @@ -57,22 +58,25 @@ spec:
periodSeconds: 60
selectPolicy: Max
----
<1> Use the `autoscaling/v2` API.
<2> Specify a name for this horizontal pod autoscaler object.
<3> Specify the API version of the object to scale:
* For a `Deployment`, `ReplicaSet`, or `Statefulset` object, use `apps/v1`.
where:
+
--
`apiVersion`:: Specifies the `autoscaling/v2` API.
`metadata.name`:: Specifies a name for this horizontal pod autoscaler object.
`spec.scaleTargetRef.apiVersion`:: Specifies the API version of the object to scale:
* For a `Deployment`, `ReplicaSet`, `Statefulset` object, use `apps/v1`.
* For a `ReplicationController`, use `v1`.
* For a `DeploymentConfig`, use `apps.openshift.io/v1`.
<4> Specify the type of object. The object must be a `Deployment`, `DeploymentConfig`,
`ReplicaSet`, `ReplicationController`, or `StatefulSet`.
<5> Specify the name of the object to scale. The object must exist.
<6> Specify the minimum number of replicas when scaling down.
<7> Specify the maximum number of replicas when scaling up.
<8> Use the `metrics` parameter for memory usage.
<9> Specify `memory` for memory usage.
<10> Set the type to `AverageValue`.
<11> Specify `averageValue` and a specific memory value.
<12> Optional: Specify a scaling policy to control the rate of scaling up or down.
`spec.scaleTargetRef.kind`:: Specifies the type of object. The object must be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
`spec.scaleTargetRef.name`:: Specifies the name of the object to scale. The object must exist.
`spec.minReplicas`:: Specifies the minimum number of replicas when scaling down.
`spec.maxReplicas`:: Specifies the maximum number of replicas when scaling up.
`spec.metrics`:: Specifies the parameters to calculate the desired replica count. Set the
`spec.metrics.resource.name`:: Specifies a name for the resource.
`spec.metrics.resource.target.type`:: Specifies the type of target, here `AverageValue` for a specific memory value.
`spec.metrics.resource.target.averageValue`:: Specifies the targeted memory value.
`spec.behavior`:: Optional: Specifies a scaling policy to control the rate of scaling up or down.
--

. Create the horizontal pod autoscaler by using a command similar to the following:
+
Expand Down
5 changes: 3 additions & 2 deletions modules/nodes-pods-autoscaling-creating-web-console-edit.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-creating-web-console-edit_{context}"]
= Editing a horizontal pod autoscaler by using the web console

From the web console, you can modify a horizontal pod autoscaler (HPA) that specifies the minimum and maximum number of pods you want to run on a `Deployment` or `DeploymentConfig` object. You can also define the amount of CPU or memory usage that your pods should target.
[role="_abstract"]
You can use the web console to modify a horizontal pod autoscaler (HPA) that specifies the minimum and maximum number of pods you want to run on a `Deployment` or `DeploymentConfig` object. You can also define the amount of CPU or memory usage that your pods should target.

.Procedure

Expand All @@ -15,7 +16,7 @@ From the web console, you can modify a horizontal pod autoscaler (HPA) that spec
. From the *Actions* drop-down list, select *Edit HorizontalPodAutoscaler* to open the *Edit Horizontal Pod Autoscaler* form.

. From the *Edit Horizontal Pod Autoscaler* form, edit the minimum and maximum pod limits and the CPU and memory usage, and click *Save*.

+
[NOTE]
====
While creating or editing the horizontal pod autoscaler in the web console, you can switch from *Form view* to *YAML view*.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[id="nodes-pods-autoscaling-creating-web-console-remove_{context}"]
= Removing a horizontal pod autoscaler by using the web console

You can remove a horizontal pod autoscaler (HPA) in the web console.
[role="_abstract"]
You can use the web console to remove a horizontal pod autoscaler (HPA).

.Procedure

Expand Down
7 changes: 4 additions & 3 deletions modules/nodes-pods-autoscaling-creating-web-console.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
[id="nodes-pods-autoscaling-creating-web-console_{context}"]
= Creating a horizontal pod autoscaler by using the web console

From the web console, you can create a horizontal pod autoscaler (HPA) that specifies the minimum and maximum number of pods you want to run on a `Deployment` or `DeploymentConfig` object. You can also define the amount of CPU or memory usage that your pods should target.
[role="_abstract"]
You can use the web console to create a horizontal pod autoscaler (HPA) that specifies the minimum and maximum number of pods you want to run on a `Deployment` or `DeploymentConfig` object. You can also define the amount of CPU or memory usage that your pods should target.

[NOTE]
====
An HPA cannot be added to deployments that are part of an Operator-backed service, Knative service, or Helm chart.
====

.Procedure
The following procedure creates an HPA in the web console.

To create an HPA in the web console:
.Procedure

. In the *Topology* view, click the node to reveal the side pane.

Expand Down
Loading