You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vertical-pod-autoscaler/enhancements/7862-cpu-startup-boost/README.md
+62-33Lines changed: 62 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,12 @@ running in containerized applications, especially Java workloads. This delay can
31
31
negatively impact the user experience and overall application performance. One
32
32
potential solution is to provide additional CPU resources to pods during their
33
33
startup phase, but this can lead to waste if the extra CPU resources are not
34
-
set back to their original values after the pods are ready.
34
+
set back to their original values after the pods have started up.
35
35
36
36
This proposal allows VPA to boost the CPU request and limit of containers during
37
-
the pod startup and to scale the CPU resources back down when the pod is `Ready`,
38
-
leveraging the [in-place pod resize Kubernetes feature](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1287-in-place-update-pod-resources).
37
+
the pod startup and to scale the CPU resources back down when the pod is
38
+
`Ready` or after certain time has elapsed, leveraging the
39
+
[in-place pod resize Kubernetes feature](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1287-in-place-update-pod-resources).
39
40
40
41
> [!NOTE]
41
42
> This feature depends on the new `InPlaceOrRecreate` VPA mode:
@@ -44,17 +45,16 @@ leveraging the [in-place pod resize Kubernetes feature](https://github.com/kuber
44
45
### Goals
45
46
46
47
* Allow VPA to boost the CPU request and limit of a pod's containers during the
47
-
pod startup (from creation time until it becomes `Ready`).
48
+
pod (re-)creation time.
48
49
* Allow VPA to scale pods down [in-place](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1287-in-place-update-pod-resources)
49
50
to the existing VPA recommendation for that container, if any, or to the CPU
50
51
resources configured in the pod spec, as soon as their [`Ready`](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions)
51
-
condition is true.
52
+
condition is true and `StartupBoost.CPU.Duration` has elapsed.
52
53
53
54
### Non-Goals
54
55
55
-
* Allow VPA to boost CPU resources of pods that are already [`Ready`](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions).
56
-
* Allow VPA to boost CPU resources during startup of workloads that have not
57
-
configured a [Readiness or a Startup probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/).
56
+
* Allow VPA to boost CPU resources of pods outside of the pod (re-)creation
57
+
time.
58
58
* Allow VPA to boost memory resources.
59
59
* This is out of scope for now because the in-place pod resize feature
60
60
[does not support memory limit decrease yet.](https://github.com/kubernetes/enhancements/tree/758ea034908515a934af09d03a927b24186af04c/keps/sig-node/1287-in-place-update-pod-resources#memory-limit-decreases)
@@ -69,6 +69,10 @@ boost.
69
69
with a new `StartupBoostOnly` mode to allow users to only enable the startup
70
70
boost feature and not vanilla VPA altogether.
71
71
72
+
* To allow CPU startup boost if a `StartupBoost` config is specified in `Auto`
@@ -83,9 +87,10 @@ limits to align with its `StartupBoost` policy, if specified, during the pod
83
87
creation.
84
88
85
89
1. The VPA Updater monitors pods targeted by the VPA object and when the pod
86
-
condition is `Ready`, it scales down the CPU resources to the appropriate
87
-
non-boosted value: `existing VPA recommendation for that container` (if any) OR
88
-
the `CPU resources configured in the pod spec`.
90
+
condition is `Ready` and `StartupBoost.CPU.Duration` has elapsed, it scales
91
+
down the CPU resources to the appropriate non-boosted value:
92
+
`existing VPA recommendation for that container` (if any) OR the
93
+
`CPU resources configured in the pod spec`.
89
94
* The scale down is applied [in-place](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1287-in-place-update-pod-resources).
90
95
91
96
### API Changes
@@ -96,6 +101,8 @@ and contain the following fields:
96
101
resource request and limit of the containers' targeted by the VPA object.
97
102
*`StartupBoost.CPU.Value`: the target value of the CPU request or limit
98
103
during the startup boost phase.
104
+
*[Optional]`StartupBoost.CPU.Duration`: if specified, it indicates for how
105
+
long to keep the pod boosted **after** it goes to `Ready`.
99
106
100
107
> [!IMPORTANT]
101
108
> The boosted CPU value will be capped by
@@ -105,6 +112,15 @@ and contain the following fields:
105
112
> [!IMPORTANT]
106
113
> Only one of `Factor` or `Value` may be specified per container policy.
107
114
115
+
116
+
> [!NOTE]
117
+
> To ensure that containers are unboosted only after their applications are
118
+
> started and ready, it is recommended to configure a
119
+
> [Readiness or a Startup probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)
120
+
> for the containers that will be CPU boosted. Check the [Test Plan](#test-plan)
121
+
> section for more details on this feature's behavior for different combinations
122
+
> of probers + `StartupBoost.CPU.Duration`.
123
+
108
124
We will also add a new mode to the [`ContainerScalingMode`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L231-L236):
109
125
***NEW**: `StartupBoostOnly`: new mode that will allow users to only enable
110
126
the startup boost feature for a container and not vanilla VPA altogether.
@@ -146,21 +162,17 @@ are created/updated:
146
162
*`StartupBoost.CPU.Value` must be greater than the CPU request or limit of the
147
163
container during the boost phase, otherwise we risk downscaling the container.
148
164
149
-
* Workloads must be configured with a Readiness or a Startup probe to be able to
150
-
utilize this feature. Therefore, VPA will not boost CPU resources of workloads
151
-
that do not configure a Readiness or a Startup probe.
152
-
153
165
### Mitigating Failed In-Place Downsizes
154
166
155
-
The VPA Updater **will not** evict a pod to actuate a startup CPU boost
156
-
recommendation if it attempted to apply the recommendation in place and it
157
-
failed (see the [scenarios](https://github.com/kubernetes/autoscaler/blob/0a34bf5d3a71b486bdaa440f1af7f8d50dc8e391/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support/README.md?plain=1#L164-L169) where the VPA
167
+
The VPA Updater **will not** evict a pod if it attempted to scaled the pod down
168
+
in place (to unboost its CPU resources) and the update failed (see the
169
+
[scenarios](https://github.com/kubernetes/autoscaler/blob/0a34bf5d3a71b486bdaa440f1af7f8d50dc8e391/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support/README.md?plain=1#L164-L169) where the VPA
158
170
updater will consider that the update failed). This is to avoid an eviction
159
171
loop:
160
172
161
173
1. A pod is created and has its CPU resources boosted
162
-
1. The pod is ready. VPA Updater tries to downscale the pod in-place and it
163
-
fails.
174
+
1. The pod meets the conditions to be unboosted. VPA Updater tries to downscale
175
+
the pod in-place and it fails.
164
176
1. VPA Updater evicts the pod. Logic flow goes back to (1).
165
177
166
178
### Feature Enablement and Rollback
@@ -189,33 +201,41 @@ the following to happen:
189
201
* admission-controller **to not** boost CPU resources, should it encounter a
190
202
VPA configured with a `StartupBoost` config and `StartupBoostOnly` or `Auto`
191
203
`ContainerScalingMode`.
192
-
* updater **to not** unboost CPU resources when pods become `Ready`, should it
193
-
encounter a VPA configured with a `StartupBoost` config and `StartupBoostOnly`
194
-
or `Auto``ContainerScalingMode`.
204
+
* updater **to not** unboost CPU resources when pods meet the scale down
205
+
requirements, should it encounter a VPA configured with a `StartupBoost`
206
+
config and `StartupBoostOnly`or `Auto``ContainerScalingMode`.
195
207
196
208
### Kubernetes Version Compatibility
197
209
198
210
Similarly to [AEP-4016](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support#kubernetes-version-compatibility),
199
211
`StartupBoost` configuration and `StartupBoostOnly` mode are built assuming that
200
212
VPA will be running on a Kubernetes 1.33+ with the beta version of
201
213
[KEP-1287: In-Place Update of Pod Resources](https://github.com/kubernetes/enhancements/issues/1287)
202
-
enabled. If this is not the case, VPA will behave as if the `CPUStartupBoost`
203
-
feature gate was disabled (see [Feature Enablement and Rollback](#feature-enablement-and-rollback)
204
-
section for details).
214
+
enabled. If this is not the case, VPA's attempt to unboost pods may fail and the
215
+
pods may remain boosted for their whole lifecycle.
205
216
206
217
## Test Plan
207
218
208
219
Other than comprehensive unit tests, we will also add the following scenarios to
209
220
our e2e tests:
210
221
211
222
* CPU Startup Boost recommendation is applied to pod controlled by VPA until it
212
-
becomes `Ready`. Then, the pod is scaled back down in-place.
223
+
becomes `Ready` and `StartupBoost.CPU.Duration` has elapsed. Then, the pod is
224
+
scaled back down in-place. We'll also test the following sub-cases:
213
225
* Boost is applied to all containers of a pod.
214
-
* Boost is applied to a subset of containers.
215
-
* CPU Startup Boost will not be applied if a pod is not configured with a
216
-
Readiness or a Startup probe.
217
-
* Pod is evicted the first time that an in-place update fails when scaling the
218
-
pod back down. And a new CPU boost is not attempted when the pod is recreated.
226
+
* Boost is applied only to a subset of containers in a pod.
227
+
* Combinations of probes + `StartupBoost.CPU.Duration`:
228
+
* No probes and no `StartupBoost.CPU.Duration` specified: unboost will
229
+
likely happen immediately.
230
+
* No probes and a 60s `StartupBoost.CPU.Duration`: unboost will likely
231
+
happen after 60s.
232
+
* A readiness/startup probe and no `StartupBoost.CPU.Duration` specified:
233
+
unboost will likely as soon as the pod becomes `Ready`.
234
+
* A readiness/startup probe and a 60s `StartupBoost.CPU.Duration`
235
+
specified: unboost will likely happen 60s **after** the pod becomes `Ready`.
236
+
237
+
* Pod is not evicted if the in-place update fails when scaling the pod back
238
+
down.
219
239
220
240
## Examples
221
241
@@ -224,6 +244,10 @@ scenarios.
224
244
225
245
### CPU Boost Only
226
246
247
+
All containers under `example` deployment will receive "regular" VPA updates,
248
+
**except for**`boosted-container-name`. `boosted-container-name` will only be
249
+
CPU boosted/unboosted, because it has a `StartupBoostOnly` container policy.
250
+
227
251
```yaml
228
252
apiVersion: "autoscaling.k8s.io/v1"
229
253
kind: VerticalPodAutoscaler
@@ -248,6 +272,11 @@ spec:
248
272
249
273
### CPU Boost and Vanilla VPA
250
274
275
+
All containers under `example` deployment will receive "regular" VPA updates,
0 commit comments