Skip to content

Commit f37cfd9

Browse files
committed
The hpa documentation should describe how to configure a hpa with Deployment and ReplicaSet
1 parent aa6af2b commit f37cfd9

File tree

3 files changed

+65
-100
lines changed

3 files changed

+65
-100
lines changed

modules/nodes-pods-autoscaling-about.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,54 @@ Use the {product-title} web console to check the memory behavior of your applica
6464
and ensure that your application meets these requirements before using
6565
memory-based autoscaling.
6666
====
67+
68+
The following example shows autoscaling for the `image-registry` `DeploymentConfig` object. The initial deployment requires 3 pods. The HPA object increased that minimum to 5 and will increase the pods up to 7 if CPU usage on the pods reaches 75%:
69+
70+
[source,terminal]
71+
----
72+
$ oc autoscale dc/image-registry --min=5 --max=7 --cpu-percent=75
73+
----
74+
75+
.Example output
76+
[source,terminal]
77+
----
78+
horizontalpodautoscaler.autoscaling/image-registry autoscaled
79+
----
80+
81+
.Sample HPA for the `image-registry` `DeploymentConfig` object with `minReplicas` set to 3
82+
[source,yaml]
83+
----
84+
apiVersion: autoscaling/v1
85+
kind: HorizontalPodAutoscaler
86+
metadata:
87+
name: image-registry
88+
namespace: default
89+
spec:
90+
maxReplicas: 7
91+
minReplicas: 3
92+
scaleTargetRef:
93+
apiVersion: apps.openshift.io/v1
94+
kind: DeploymentConfig
95+
name: image-registry
96+
targetCPUUtilizationPercentage: 75
97+
status:
98+
currentReplicas: 5
99+
desiredReplicas: 0
100+
----
101+
102+
103+
. View the new state of the deployment:
104+
+
105+
[source,terminal]
106+
----
107+
$ oc get dc image-registry
108+
----
109+
+
110+
There are now 5 pods in the deployment:
111+
+
112+
.Example output
113+
[source,terminal]
114+
----
115+
NAME REVISION DESIRED CURRENT TRIGGERED BY
116+
image-registry 1 5 5 config
117+
----

modules/nodes-pods-autoscaling-creating-cpu.adoc

Lines changed: 13 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
= Creating a horizontal pod autoscaler for CPU utilization by using the CLI
88

9-
You can create a horizontal pod autoscaler (HPA) for an existing `DeploymentConfig` or `ReplicationController` object
10-
that automatically scales the pods associated with that object to maintain the CPU usage you specify.
9+
You can create a horizontal pod autoscaler (HPA) for an existing `Deployment`, `DeploymentConfig`, `ReplicaSet`, `ReplicationController`, or `StatefulSet` object that automatically scales the pods associated with that object to maintain the CPU usage you specify.
1110

1211
The HPA increases and decreases the number of replicas between the minimum and maximum numbers to maintain the specified CPU utilization across all pods.
1312

@@ -56,37 +55,29 @@ To create a horizontal pod autoscaler for CPU utilization:
5655

5756
. Perform one of the following one of the following:
5857

59-
** To scale based on the percent of CPU utilization, create a `HorizontalPodAutoscaler` object for an existing `DeploymentConfig` object:
58+
** To scale based on the percent of CPU utilization, create a `HorizontalPodAutoscaler` object for an existing object:
6059
+
6160
[source,terminal]
6261
----
63-
$ oc autoscale dc/<dc-name> \// <1>
62+
$ oc autoscale <object_type>/<name> \// <1>
6463
--min <number> \// <2>
6564
--max <number> \// <3>
6665
--cpu-percent=<percent> <4>
6766
----
6867
+
69-
<1> Specify the name of the `DeploymentConfig` object. The object must exist.
68+
<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`.
7069
<2> Optionally, specify the minimum number of replicas when scaling down.
7170
<3> Specify the maximum number of replicas when scaling up.
7271
<4> Specify the target average CPU utilization over all the pods, represented as a percent of requested CPU. If not specified or negative, a default autoscaling policy is used.
73-
74-
** To scale based on the percent of CPU utilization, create a `HorizontalPodAutoscaler` object for an existing replication controller:
72+
+
73+
For example, the following command shows autoscaling for the `image-registry` `DeploymentConfig` object. The initial deployment requires 3 pods. The HPA object increased that minimum to 5 and will increase the pods up to 7 if CPU usage on the pods reaches 75%:
7574
+
7675
[source,terminal]
7776
----
78-
$ oc autoscale rc/<rc-name> <1>
79-
--min <number> \// <2>
80-
--max <number> \// <3>
81-
--cpu-percent=<percent> <4>
77+
$ oc autoscale dc/image-registry --min=5 --max=7 --cpu-percent=75
8278
----
83-
+
84-
<1> Specify the name of the replication controller. The object must exist.
85-
<2> Specify the minimum number of replicas when scaling down.
86-
<3> Specify the maximum number of replicas when scaling up.
87-
<4> Specify the target average CPU utilization over all the pods, represented as a percent of requested CPU. If not specified or negative, a default autoscaling policy is used.
8879

89-
** To scale for a specific CPU value, create a YAML file similar to the following for an existing `DeploymentConfig` object or replication controller:
80+
** To scale for a specific CPU value, create a YAML file similar to the following for an existing object:
9081
+
9182
.. Create a YAML file similar to the following:
9283
+
@@ -100,7 +91,7 @@ metadata:
10091
spec:
10192
scaleTargetRef:
10293
apiVersion: v1 <3>
103-
kind: ReplicationController <4>
94+
kind: ReplicaSet <4>
10495
name: example <5>
10596
minReplicas: 1 <6>
10697
maxReplicas: 10 <7>
@@ -115,9 +106,10 @@ spec:
115106
<1> Use the `autoscaling/v2beta2` API.
116107
<2> Specify a name for this horizontal pod autoscaler object.
117108
<3> Specify the API version of the object to scale:
118-
* For a replication controller, use `v1`,
119-
* For a `DeploymentConfig` object, use `apps.openshift.io/v1`.
120-
<4> Specify the kind of object to scale, either `ReplicationController` or `DeploymentConfig`.
109+
* For a `ReplicationController`, use `v1`.
110+
* For a `DeploymentConfig`, use `apps.openshift.io/v1`.
111+
* For a `Deployment`, `ReplicaSet`, `Statefulset` object, use `apps/v1`.
112+
<4> Specify the type of object. The object must be a `Deployment`, `DeploymentConfig`/`dc`, `ReplicaSet`/`rs`, `ReplicationController`/`rc`, or `StatefulSet`.
121113
<5> Specify the name of the object to scale. The object must exist.
122114
<6> Specify the minimum number of replicas when scaling down.
123115
<7> Specify the maximum number of replicas when scaling up.
@@ -147,81 +139,3 @@ NAME REFERENCE TARGETS MINPODS MAXPOD
147139
cpu-autoscale ReplicationController/example 173m/500m 1 10 1 20m
148140
----
149141

150-
For example, the following command creates a horizontal pod autoscaler that maintains between 3 and 7 replicas of the pods that are controlled by the `image-registry` `DeploymentConfig` object to maintain an average CPU utilization of 75% across all pods.
151-
152-
[source,terminal]
153-
----
154-
$ oc autoscale dc/image-registry --min 3 --max 7 --cpu-percent=75
155-
----
156-
157-
.Example output
158-
[source,terminal]
159-
----
160-
horizontalpodautoscaler.autoscaling/image-registry autoscaled
161-
----
162-
163-
.Sample HPA for the `image-registry` `DeploymentConfig` object with `minReplicas` set to 3
164-
[source,yaml]
165-
----
166-
apiVersion: autoscaling/v1
167-
kind: HorizontalPodAutoscaler
168-
metadata:
169-
name: image-registry
170-
namespace: default
171-
spec:
172-
maxReplicas: 7
173-
minReplicas: 3
174-
scaleTargetRef:
175-
apiVersion: apps.openshift.io/v1
176-
kind: DeploymentConfig
177-
name: image-registry
178-
targetCPUUtilizationPercentage: 75
179-
status:
180-
currentReplicas: 5
181-
desiredReplicas: 0
182-
----
183-
184-
The following example shows autoscaling for the `image-registry` `DeploymentConfig` object. The initial deployment requires 3 pods. The HPA object increased that minimum to 5 and will increase the pods up to 7 if CPU usage on the pods reaches 75%:
185-
186-
. View the current state of the `image-registry` deployment:
187-
+
188-
[source,terminal]
189-
----
190-
$ oc get dc image-registry
191-
----
192-
+
193-
.Example output
194-
[source,terminal]
195-
----
196-
NAME REVISION DESIRED CURRENT TRIGGERED BY
197-
image-registry 1 3 3 config
198-
----
199-
200-
. Autoscale the `image-registry` `DeploymentConfig` object:
201-
+
202-
[source,terminal]
203-
----
204-
$ oc autoscale dc/image-registry --min=5 --max=7 --cpu-percent=75
205-
----
206-
+
207-
.Example output
208-
[source,terminal]
209-
----
210-
horizontalpodautoscaler.autoscaling/image-registry autoscaled
211-
----
212-
213-
. View the new state of the deployment:
214-
+
215-
[source,terminal]
216-
----
217-
$ oc get dc image-registry
218-
----
219-
+
220-
There are now 5 pods in the deployment:
221-
+
222-
.Example output
223-
[source,terminal]
224-
----
225-
NAME REVISION DESIRED CURRENT TRIGGERED BY
226-
image-registry 1 5 5 config
227-
----

modules/nodes-pods-autoscaling-creating-memory.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To create a horizontal pod autoscaler for memory utilization:
5858

5959
. Create a YAML file for one of the following:
6060

61-
** To scale for a specific memory value, create a `HorizontalPodAutoscaler` object similar to the following for an existing `DeploymentConfig` object or replication controller:
61+
** To scale for a specific memory value, create a `HorizontalPodAutoscaler` object similar to the following for an existing `ReplicationController` object or replication controller:
6262
+
6363
.Example output
6464
[source,yaml,options="nowrap"]

0 commit comments

Comments
 (0)