Skip to content

Commit e1e52f6

Browse files
authored
Merge pull request #44364 from mburke5678/OSDOCS-3446-custom-autoscaler
OCDOCS-3446: Recommend support of alternative VPA recommender to the community
2 parents 7dd269f + 2c4d2be commit e1e52f6

4 files changed

+180
-3
lines changed

modules/nodes-pods-vertical-autoscaler-about.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
The Vertical Pod Autoscaler Operator (VPA) is implemented as an API resource and a custom resource (CR). The CR determines the actions the Vertical Pod Autoscaler Operator should take with the pods associated with a specific workload object, such as a daemon set, replication controller, and so forth, in a project.
1010

11-
The VPA automatically computes historic and current CPU and memory usage for the containers in those pods and uses this data to determine optimized resource limits and requests to ensure that these pods are operating efficiently at all times. For example, the VPA reduces resources for pods that are requesting more resources than they are using and increases resources for pods that are not requesting enough.
11+
You can use the default recommender or use your own alternative recommender to autoscale based on your own algorithms.
1212

13-
The VPA automatically deletes any pods that are out of alignment with its recommendations one at a time, so that your applications can continue to serve requests with no downtime. The workload objects then re-deploy the pods with the original resource limits and requests. The VPA uses a mutating admission webhook to update the pods with optimized resource limits and requests before the pods are admitted to a node. If you do not want the VPA to delete pods, you can view the VPA resource limits and requests and manually update the pods as needed.
13+
The default recommender automatically computes historic and current CPU and memory usage for the containers in those pods and uses this data to determine optimized resource limits and requests to ensure that these pods are operating efficiently at all times. For example, the default recommender suggests reduced resources for pods that are requesting more resources than they are using and increased resources for pods that are not requesting enough.
14+
15+
The VPA then automatically deletes any pods that are out of alignment with these recommendations one at a time, so that your applications can continue to serve requests with no downtime. The workload objects then re-deploy the pods with the original resource limits and requests. The VPA uses a mutating admission webhook to update the pods with optimized resource limits and requests before the pods are admitted to a node. If you do not want the VPA to delete pods, you can view the VPA resource limits and requests and manually update the pods as needed.
1416

1517
[NOTE]
1618
====

modules/nodes-pods-vertical-autoscaler-configuring.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
You can use the Vertical Pod Autoscaler Operator (VPA) by creating a VPA custom resource (CR). The CR indicates which pods it should analyze and determines the actions the VPA should take with those pods.
1010

11+
.Prerequisites
12+
13+
* The workload object that you want to autoscale must exist.
14+
15+
* If you want to use an alternative recommender, a deployment including that recommender must exist.
16+
1117
.Procedure
1218

1319
To create a VPA CR for a specific workload object:
@@ -33,6 +39,8 @@ spec:
3339
containerPolicies:
3440
- containerName: my-opt-sidecar
3541
mode: "Off"
42+
recommenders: <5>
43+
- name: my-recommender
3644
----
3745
<1> Specify the type of workload object you want this VPA to manage: `Deployment`, `StatefulSet`, `Job`, `DaemonSet`, `ReplicaSet`, or `ReplicationController`.
3846
<2> Specify the name of an existing workload object you want this VPA to manage.
@@ -42,7 +50,7 @@ spec:
4250
* `initial` to automatically apply the recommended resources when pods associated with the workload object are created. The VPA does not update the pods as it learns new resource recommendations.
4351
* `off` to only generate resource recommendations for the pods associated with the workload object. The VPA does not update the pods as it learns new resource recommendations and does not apply the recommendations to new pods.
4452
<4> Optional. Specify the containers you want to opt-out and set the mode to `Off`.
45-
53+
<5> Optional. Specify an alternative recommender.
4654

4755
.. Create the VPA CR:
4856
+
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * nodes/nodes-vertical-autoscaler.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="nodes-pods-vertical-autoscaler-custom_{context}"]
7+
= Using an alternative recommender
8+
9+
You can use your own recommender to autoscale based on your own algorithms. If you do not specify an alternative recommender, {product-title} uses the default recommender, which suggests CPU and memory requests based on historical usage. Because there is no universal recommendation policy that applies to all types of workloads, you might want to create and deploy different recommenders for specific workloads.
10+
11+
For example, the default recommender might not accurately predict future resource usage when containers exhibit certain resource behaviors, such as cyclical patterns that alternate between usage spikes and idling as used by monitoring applications, or recurring and repeating patterns used with deep learning applications. Using the default recommender with these usage behaviors might result in significant over-provisioning and Out of Memory (OOM) kills for your applications.
12+
13+
// intro paragraph based on https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/3919-customized-recommender-vpa
14+
15+
[NOTE]
16+
====
17+
Instructions for how to create a recommender are beyond the scope of this documentation,
18+
====
19+
20+
.Procedure
21+
22+
To use an alternative recommender for your pods:
23+
24+
. Create a service account for the alternative recommender and bind that service account to the required cluster role:
25+
+
26+
[source,yaml]
27+
----
28+
apiVersion: v1 <1>
29+
kind: ServiceAccount
30+
metadata:
31+
name: alt-vpa-recommender-sa
32+
namespace: <namespace_name>
33+
---
34+
apiVersion: rbac.authorization.k8s.io/v1 <2>
35+
kind: ClusterRoleBinding
36+
metadata:
37+
name: system:example-metrics-reader
38+
roleRef:
39+
apiGroup: rbac.authorization.k8s.io
40+
kind: ClusterRole
41+
name: system:metrics-reader
42+
subjects:
43+
- kind: ServiceAccount
44+
name: alt-vpa-recommender-sa
45+
namespace: <namespace_name>
46+
---
47+
apiVersion: rbac.authorization.k8s.io/v1 <3>
48+
kind: ClusterRoleBinding
49+
metadata:
50+
name: system:example-vpa-actor
51+
roleRef:
52+
apiGroup: rbac.authorization.k8s.io
53+
kind: ClusterRole
54+
name: system:vpa-actor
55+
subjects:
56+
- kind: ServiceAccount
57+
name: alt-vpa-recommender-sa
58+
namespace: <namespace_name>
59+
---
60+
apiVersion: rbac.authorization.k8s.io/v1 <4>
61+
kind: ClusterRoleBinding
62+
metadata:
63+
name: system:example-vpa-target-reader-binding
64+
roleRef:
65+
apiGroup: rbac.authorization.k8s.io
66+
kind: ClusterRole
67+
name: system:vpa-target-reader
68+
subjects:
69+
- kind: ServiceAccount
70+
name: alt-vpa-recommender-sa
71+
namespace: <namespace_name>
72+
----
73+
<1> Creates a service accocunt for the recommender in the namespace where the recommender is deployed.
74+
<2> Binds the recommender service account to the `metrics-reader` role. Specify the namespace where the recommender is to be deployed.
75+
<3> Binds the recommender service account to the `vpa-actor` role. Specify the namespace where the recommender is to be deployed.
76+
<4> Binds the recommender service account to the `vpa-target-reader` role. Specify the namespace where the recommender is to be deployed.
77+
78+
. To add the alternative recommender to the cluster, create a Deployment object similar to the following:
79+
+
80+
[source,yaml]
81+
----
82+
apiVersion: apps/v1
83+
kind: Deployment
84+
metadata:
85+
name: alt-vpa-recommender
86+
namespace: <namespace_name>
87+
spec:
88+
replicas: 1
89+
selector:
90+
matchLabels:
91+
app: alt-vpa-recommender
92+
template:
93+
metadata:
94+
labels:
95+
app: alt-vpa-recommender
96+
spec:
97+
containers: <1>
98+
- name: recommender
99+
image: quay.io/example/alt-recommender:latest <2>
100+
imagePullPolicy: Always
101+
resources:
102+
limits:
103+
cpu: 200m
104+
memory: 1000Mi
105+
requests:
106+
cpu: 50m
107+
memory: 500Mi
108+
ports:
109+
- name: prometheus
110+
containerPort: 8942
111+
securityContext:
112+
allowPrivilegeEscalation: false
113+
capabilities:
114+
drop:
115+
- ALL
116+
seccompProfile:
117+
type: RuntimeDefault
118+
serviceAccountName: alt-vpa-recommender-sa <3>
119+
securityContext:
120+
runAsNonRoot: true
121+
----
122+
+
123+
--
124+
<1> Creates a container for your alternative recommender.
125+
<2> Specifies your recommender image.
126+
<3> Associates the service account that you created for the recommender.
127+
--
128+
+
129+
A new pod is created for the alternative recommender in the same namespace.
130+
+
131+
[source,terminal]
132+
----
133+
$ oc get pods
134+
----
135+
+
136+
.Example output
137+
[source,terminal]
138+
----
139+
NAME READY STATUS RESTARTS AGE
140+
frontend-845d5478d-558zf 1/1 Running 0 4m25s
141+
frontend-845d5478d-7z9gx 1/1 Running 0 4m25s
142+
frontend-845d5478d-b7l4j 1/1 Running 0 4m25s
143+
vpa-alt-recommender-55878867f9-6tp5v 1/1 Running 0 9s
144+
----
145+
146+
. Configure a VPA CR that includes the name of the alternative recommender `Deployment` object.
147+
+
148+
.Example VPA CR to include the alternative recommender
149+
[source,yml]
150+
----
151+
apiVersion: autoscaling.k8s.io/v1
152+
kind: VerticalPodAutoscaler
153+
metadata:
154+
name: vpa-recommender
155+
namespace: <namespace_name>
156+
spec:
157+
recommenders:
158+
- name: alt-vpa-recommender <1>
159+
targetRef:
160+
apiVersion: "apps/v1"
161+
kind: Deployment <2>
162+
name: frontend
163+
----
164+
<1> Specifies the name of the alternative recommender deployment.
165+
<2> Specifies the name of an existing workload object you want this VPA to manage.

nodes/pods/nodes-pods-vertical-autoscaler.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ include::modules/nodes-pods-vertical-autoscaler-install.adoc[leveloffset=+1]
2424

2525
include::modules/nodes-pods-vertical-autoscaler-using-about.adoc[leveloffset=+1]
2626

27+
include::modules/nodes-pods-vertical-autoscaler-custom.adoc[leveloffset=+2]
28+
2729
include::modules/nodes-pods-vertical-autoscaler-configuring.adoc[leveloffset=+1]
2830

2931
include::modules/nodes-pods-vertical-autoscaler-uninstall.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)