Skip to content

Commit ea041d5

Browse files
committed
Decouple Startup CPU Boost from VPA modes
1 parent fabcbe5 commit ea041d5

File tree

1 file changed

+135
-56
lines changed
  • vertical-pod-autoscaler/enhancements/7862-cpu-startup-boost

1 file changed

+135
-56
lines changed

vertical-pod-autoscaler/enhancements/7862-cpu-startup-boost/README.md

Lines changed: 135 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ the pod startup and to scale the CPU resources back down when the pod is
3838
`Ready` or after certain time has elapsed, leveraging the
3939
[in-place pod resize Kubernetes feature](https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/1287-in-place-update-pod-resources).
4040

41-
> [!NOTE]
42-
> This feature depends on the new `InPlaceOrRecreate` VPA mode:
43-
> [AEP-4016: Support for in place updates in VPA](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support/README.md)
44-
4541
### Goals
4642

4743
* Allow VPA to boost the CPU request and limit of a pod's containers during the
@@ -61,17 +57,16 @@ time.
6157

6258
## Proposal
6359

64-
* To extend [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191)
60+
* To extend [`VerticalPodAutoscalerSpec`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L75)
6561
with a new `StartupBoost` field to allow users to configure the CPU startup
6662
boost.
6763

68-
* To extend [`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)
69-
with a new `StartupBoostOnly` mode to allow users to only enable the startup
70-
boost feature and not vanilla VPA altogether.
64+
* To extend [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191)
65+
with a new `StartupBoost` field to allow users to optionally customize the
66+
startup boost behavior for individual containers.
7167

72-
* To allow CPU startup boost if a `StartupBoost` config is specified in `Auto`
73-
[`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)
74-
container policies.
68+
* To enable only startup boost (if the `StartupBoost` config is present in the
69+
VPA object) without having to ALSO use the traditional VPA functionality.
7570

7671
## Design Details
7772

@@ -95,8 +90,15 @@ down the CPU resources to the appropriate non-boosted value:
9590

9691
### API Changes
9792

98-
The new `StartupBoost` parameter will be added to the [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191)
99-
and contain the following fields:
93+
The new `StartupBoost` parameter will be added to both:
94+
* [`VerticalPodAutoscalerSpec`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L75):
95+
Will allow users to specify the default CPU startup boost for all containers of the pod targeted by the VPA object.
96+
* [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191):
97+
Will allow users to optionally customize the startup boost behavior for individual containers.
98+
99+
`StartupBoost` will contain the following fields:
100+
* [Optional] `StartupBoost.CPU.Mode`: whether CPU boost is enabled (`"Auto"`)
101+
or not (`"Off"`). If not specified, it defaults to `"Auto"`.
100102
* `StartupBoost.CPU.Factor`: the factor by which to multiply the initial
101103
resource request and limit of the containers' targeted by the VPA object.
102104
* `StartupBoost.CPU.Value`: the target value of the CPU request or limit
@@ -121,22 +123,15 @@ and contain the following fields:
121123
> section for more details on this feature's behavior for different combinations
122124
> of probers + `StartupBoost.CPU.Duration`.
123125
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):
125-
* **NEW**: `StartupBoostOnly`: new mode that will allow users to only enable
126-
the startup boost feature for a container and not vanilla VPA altogether.
127-
* **NEW**: `Auto`: we will modify the existing `Auto` mode to enable both
128-
vanilla VPA and CPU Startup Boost (when `StartupBoost` parameter is
129-
specified).
130-
131126
#### Priority of `StartupBoost`
132127

133-
The new `StartupBoost` field will take precedence over the rest of the container
134-
resource policy configurations. Functioning independently from all other fields
135-
in [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191),
128+
The new `StartupBoost` field will take precedence over the rest of the fields
129+
in [`VerticalPodAutoscalerSpec`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L75)
130+
and [`ContainerResourcePolicy`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L191),
136131
**except for**:
137-
* [`ContainerName`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L192-L195)
138-
* [`Mode`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L196-L198)
139-
* [`ControlledValues`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L214-L217)
132+
* [`VerticalPodAutoscalerSpec.TargetRef`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L88)
133+
* [`ContainerResourcePolicy.ContainerName`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L192-L195)
134+
* [`ContainerResourcePolicy.ControlledValues`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L214-L217)
140135

141136
This means that a container's CPU request/limit can be boosted during startup
142137
beyond [`MaxAllowed`](https://github.com/kubernetes/autoscaler/blob/vertical-pod-autoscaler-1.3.0/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go#L203-L206),
@@ -149,12 +144,11 @@ excluded from [`ControlledResources`](https://github.com/kubernetes/autoscaler/b
149144

150145
* We will check that the `startupBoost` configuration is valid when VPA objects
151146
are created/updated:
152-
* The VPA autoscaling mode must be `InPlaceOrRecreate` (since it does not
153-
make sense to use this feature with disruptive modes of VPA).
154147
* The boost factor is >= 1 (via CRD validation rules)
155148
* Only one of `StartupBoost.CPU.Factor` or `StartupBoost.CPU.Value` is
156149
specified
157-
* The [feature enablement](#feature-enablement) flags must be on.
150+
* The [feature enablement](#feature-enablement-and-rollback) flags must be
151+
on.
158152

159153

160154
#### Dynamic Validation
@@ -166,7 +160,7 @@ are created/updated:
166160

167161
The VPA Updater **will not** evict a pod if it attempted to scaled the pod down
168162
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
163+
[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
170164
updater will consider that the update failed). This is to avoid an eviction
171165
loop:
172166

@@ -179,37 +173,33 @@ the pod in-place and it fails.
179173

180174
#### How can this feature be enabled / disabled in a live cluster?
181175

182-
* Feature gates names: `CPUStartupBoost` and `InPlaceOrRecreate` (from
183-
[AEP-4016](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support/README.md#feature-enablement-and-rollback))
176+
* Feature gates name: `CPUStartupBoost`
184177
* Components depending on the feature gates:
185178
* admission-controller
186179
* updater
187180

188-
Enabling of feature gates `CPUStartupBoost` AND `InPlaceOrRecreate` will cause
189-
the following to happen:
181+
Enabling of feature gates `CPUStartupBoost` will cause the following to happen:
190182
* admission-controller to **accept** new VPA objects being created with
191-
`StartupBoostOnly` configured.
183+
`StartupBoost` configured.
192184
* admission-controller to **boost** CPU resources.
193185
* updater to **unboost** the CPU resources.
194186

195-
Disabling of feature gates `CPUStartupBoost` OR `InPlaceOrRecreate` will cause
196-
the following to happen:
187+
Disabling of feature gates `CPUStartupBoost` will cause the following to happen:
197188
* admission-controller to **reject** new VPA objects being created with
198-
`StartupBoostOnly` configured.
189+
`StartupBoost` configured.
199190
* A descriptive error message should be returned to the user letting them
200191
know that they are using a feature gated feature.
201192
* admission-controller **to not** boost CPU resources, should it encounter a
202-
VPA configured with a `StartupBoost` config and `StartupBoostOnly` or `Auto`
203-
`ContainerScalingMode`.
193+
VPA configured with a `StartupBoost` config.
204194
* updater **to not** unboost CPU resources when pods meet the scale down
205195
requirements, should it encounter a VPA configured with a `StartupBoost`
206-
config and `StartupBoostOnly` or `Auto` `ContainerScalingMode`.
196+
config.
207197

208198
### Kubernetes Version Compatibility
209199

210200
Similarly to [AEP-4016](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support#kubernetes-version-compatibility),
211-
`StartupBoost` configuration and `StartupBoostOnly` mode are built assuming that
212-
VPA will be running on a Kubernetes 1.33+ with the beta version of
201+
`StartupBoost` configuration is built assuming that VPA will be running on a
202+
Kubernetes 1.33+ with the beta version of
213203
[KEP-1287: In-Place Update of Pod Resources](https://github.com/kubernetes/enhancements/issues/1287)
214204
enabled. If this is not the case, VPA's attempt to unboost pods may fail and the
215205
pods may remain boosted for their whole lifecycle.
@@ -242,11 +232,47 @@ down.
242232
Here are some examples of the VPA CR incorporating CPU boosting for different
243233
scenarios.
244234

245-
### CPU Boost Only
235+
### Per-pod configurations (`startupBoost` configured in `VerticalPodAutoscalerSpec`)
246236

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.
237+
#### Startup CPU Boost Enabled & VPA Disabled
238+
239+
```yaml
240+
apiVersion: "autoscaling.k8s.io/v1"
241+
kind: VerticalPodAutoscaler
242+
metadata:
243+
name: example-vpa
244+
spec:
245+
targetRef:
246+
apiVersion: "apps/v1"
247+
kind: Deployment
248+
name: example
249+
updatePolicy:
250+
# This only disables VPA actuations. It doesn't disable
251+
# startup boost configurations.
252+
updateMode: "Off"
253+
startupBoost:
254+
cpu:
255+
value: 3.0
256+
duration: 10s
257+
```
258+
259+
#### Startup CPU Boost Disabled & VPA Enabled
260+
261+
```yaml
262+
apiVersion: "autoscaling.k8s.io/v1"
263+
kind: VerticalPodAutoscaler
264+
metadata:
265+
name: example-vpa
266+
spec:
267+
targetRef:
268+
apiVersion: "apps/v1"
269+
kind: Deployment
270+
name: example
271+
updatePolicy:
272+
updateMode: "Auto"
273+
```
274+
275+
#### Startup CPU Boost Enabled & VPA Enabled
250276
251277
```yaml
252278
apiVersion: "autoscaling.k8s.io/v1"
@@ -259,23 +285,77 @@ spec:
259285
kind: Deployment
260286
name: example
261287
updatePolicy:
262-
# VPA Update mode must be InPlaceOrRecreate
263-
updateMode: "InPlaceOrRecreate"
288+
updateMode: "Auto"
289+
startupBoost:
290+
cpu:
291+
value: 3.0
292+
duration: 10s
293+
```
294+
295+
### Per-container configurations (`startupBoost` configured in `ContainerPolicies`)
296+
297+
#### Startup CPU Boost Enabled & VPA Disabled
298+
299+
All containers under `example` deployment will receive "regular" VPA updates
300+
(VPA is in `"Auto"` mode in this example), **except for**
301+
`boosted-container-name`. `boosted-container-name` will only be CPU
302+
boosted/unboosted (`StartupBoost` is enabled and VPA `Mode` is set to `Off`).
303+
304+
```yaml
305+
apiVersion: "autoscaling.k8s.io/v1"
306+
kind: VerticalPodAutoscaler
307+
metadata:
308+
name: example-vpa
309+
spec:
310+
targetRef:
311+
apiVersion: "apps/v1"
312+
kind: Deployment
313+
name: example
264314
resourcePolicy:
265315
containerPolicies:
266316
- containerName: "boosted-container-name"
267-
mode: "StartupBoostOnly"
317+
# VPA mode is set to Off, so it never changes pod resources for this
318+
# container. This setting is independent from the startup boost mode.
319+
# CPU startup boost changes will still be applied (mode Auto).
320+
mode: "Off"
268321
startupBoost:
322+
mode: "Auto"
269323
cpu:
270324
factor: 2.0
271325
```
272326

273-
### CPU Boost and Vanilla VPA
327+
#### Startup CPU Boost Disabled & VPA Enabled
328+
329+
All containers under `example` deployment will receive "regular" VPA updates
330+
and be CPU boosted/unboosted, except for `disable-cpu-boost-for-this-container`.
331+
It has a `containerPolicy` `startupBoost` overriding the global VPA config.
332+
333+
```yaml
334+
apiVersion: "autoscaling.k8s.io/v1"
335+
kind: VerticalPodAutoscaler
336+
metadata:
337+
name: example-vpa
338+
spec:
339+
targetRef:
340+
apiVersion: "apps/v1"
341+
kind: Deployment
342+
name: example
343+
startupBoost:
344+
cpu:
345+
factor: 2.0
346+
resourcePolicy:
347+
containerPolicies:
348+
- containerName: "disable-cpu-boost-for-this-container"
349+
startupBoost:
350+
mode: "Off"
351+
```
352+
353+
#### Startup CPU Boost Enabled & VPA Enabled
274354

275355
All containers under `example` deployment will receive "regular" VPA updates,
276356
**including** `boosted-container-name`. Additionally, `boosted-container-name`
277357
will be CPU boosted/unboosted, because it has a `StartupBoost` config in its
278-
container policy and `Auto` container policy mode.
358+
container policy.
279359

280360
```yaml
281361
apiVersion: "autoscaling.k8s.io/v1"
@@ -287,13 +367,9 @@ spec:
287367
apiVersion: "apps/v1"
288368
kind: Deployment
289369
name: example
290-
updatePolicy:
291-
# VPA Update mode must be InPlaceOrRecreate
292-
updateMode: "InPlaceOrRecreate"
293370
resourcePolicy:
294371
containerPolicies:
295372
- containerName: "boosted-container-name"
296-
mode: "Auto" # Vanilla VPA mode + Startup Boost
297373
minAllowed:
298374
cpu: "250m"
299375
memory: "100Mi"
@@ -308,5 +384,8 @@ spec:
308384

309385
## Implementation History
310386

387+
* 2025-05-27: Decouple Startup CPU Boost from InPlaceOrRecreate mode, allow
388+
users to specify a `startupBoost` config in `VerticalPodAutoscalerSpec` and in
389+
`ContainerPolicies` to make the API simpler and add more yaml examples.
311390
* 2025-03-20: Initial version.
312391

0 commit comments

Comments
 (0)