Skip to content

Commit 89d5553

Browse files
committed
Introduce API changes and fetaure gate CPU startup boost
1 parent 2289138 commit 89d5553

File tree

8 files changed

+514
-5
lines changed

8 files changed

+514
-5
lines changed

vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,94 @@ spec:
372372
- Auto
373373
- "Off"
374374
type: string
375+
startupBoost:
376+
description: |-
377+
StartupBoost specifies the startup boost policy for the container.
378+
This overrides any pod-level startup boost policy.
379+
properties:
380+
cpu:
381+
description: |-
382+
CPU specifies the CPU startup boost policy.
383+
If this field is not set, no startup boost is applied.
384+
properties:
385+
duration:
386+
description: |-
387+
Duration indicates for how long to keep the pod boosted after it goes to Ready.
388+
Defaults to 0s.
389+
type: string
390+
factor:
391+
description: |-
392+
Factor specifies the factor to apply to the CPU request.
393+
This field is to be used only when Type is "Factor".
394+
format: int32
395+
type: integer
396+
quantity:
397+
anyOf:
398+
- type: integer
399+
- type: string
400+
description: |-
401+
Quantity specifies the absolute CPU resource quantity.
402+
This field is to be used only when Type is "Quantity".
403+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
404+
x-kubernetes-int-or-string: true
405+
type:
406+
description: |-
407+
Type specifies the kind of boost to apply.
408+
Supported values are: "Factor", "Quantity".
409+
Defaults to "Factor".
410+
enum:
411+
- Factor
412+
- Quantity
413+
type: string
414+
required:
415+
- type
416+
type: object
417+
type: object
375418
type: object
376419
type: array
377420
type: object
421+
startupBoost:
422+
description: StartupBoost specifies the startup boost policy for the
423+
pod.
424+
properties:
425+
cpu:
426+
description: |-
427+
CPU specifies the CPU startup boost policy.
428+
If this field is not set, no startup boost is applied.
429+
properties:
430+
duration:
431+
description: |-
432+
Duration indicates for how long to keep the pod boosted after it goes to Ready.
433+
Defaults to 0s.
434+
type: string
435+
factor:
436+
description: |-
437+
Factor specifies the factor to apply to the CPU request.
438+
This field is to be used only when Type is "Factor".
439+
format: int32
440+
type: integer
441+
quantity:
442+
anyOf:
443+
- type: integer
444+
- type: string
445+
description: |-
446+
Quantity specifies the absolute CPU resource quantity.
447+
This field is to be used only when Type is "Quantity".
448+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
449+
x-kubernetes-int-or-string: true
450+
type:
451+
description: |-
452+
Type specifies the kind of boost to apply.
453+
Supported values are: "Factor", "Quantity".
454+
Defaults to "Factor".
455+
enum:
456+
- Factor
457+
- Quantity
458+
type: string
459+
required:
460+
- type
461+
type: object
462+
type: object
378463
targetRef:
379464
description: |-
380465
TargetRef points to the controller managing the set of pods for the

vertical-pod-autoscaler/docs/features.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [CPU Recommendation Rounding](#cpu-recommendation-rounding)
88
- [Memory Recommendation Rounding](#memory-recommendation-rounding)
99
- [In-Place Updates](#in-place-updates-inplaceorrecreate)
10+
- [CPU Boost](#cpu-startup-boost)
1011

1112
## Limits control
1213

@@ -80,7 +81,7 @@ To enable this feature, set the `--round-memory-bytes` flag when running the VPA
8081

8182
## In-Place Updates (`InPlaceOrRecreate`)
8283

83-
> [!WARNING]
84+
> [!WARNING]
8485
> FEATURE STATE: VPA v1.4.0 [alpha]
8586
8687
VPA supports in-place updates to reduce disruption when applying resource recommendations. This feature leverages Kubernetes' in-place update capabilities (which is in beta as of Kubernetes 1.33) to modify container resources without requiring pod recreation.
@@ -124,7 +125,7 @@ Enable the feature by setting the following flags in VPA components ( for both u
124125

125126
```bash
126127
--feature-gates=InPlaceOrRecreate=true
127-
```
128+
```
128129

129130
### Limitations
130131

@@ -151,4 +152,61 @@ VPA provides metrics to track in-place update operations:
151152
* `vpa_in_place_updated_pods_total`: Number of pods successfully updated in-place
152153
* `vpa_vpas_with_in_place_updatable_pods_total`: Number of VPAs with pods eligible for in-place updates
153154
* `vpa_vpas_with_in_place_updated_pods_total`: Number of VPAs with successfully in-place updated pods
154-
* `vpa_updater_failed_in_place_update_attempts_total`: Number of failed attempts to update pods in-place.
155+
* `vpa_updater_failed_in_place_update_attempts_total`: Number of failed attempts to update pods in-place.
156+
157+
## CPU Startup Boost
158+
159+
> [!WARNING]
160+
> FEATURE STATE: VPA v1.5.0 [alpha]
161+
162+
The CPU Startup Boost feature allows VPA to temporarily increase CPU requests and limits for containers during pod startup. This can help workloads that have high CPU demands during their initialization phase, such as Java applications, to start faster. Once the pod is considered `Ready` and an optional duration has passed, VPA scales the CPU resources back down to their normal levels using an in-place resize.
163+
164+
For more details, see [AEP-7862: CPU Startup Boost](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/7862-cpu-startup-boost).
165+
166+
### Usage
167+
168+
CPU Startup Boost is configured via the `startupBoost` field in the `VerticalPodAutoscalerSpec` or within the per-container `containerPolicies`. This allows for both global and per-container boost configurations.
169+
170+
This example enables a startup boost for all containers in the targeted deployment. The CPU will be multiplied by a factor of 3 for 10 seconds after the pod becomes ready.
171+
172+
```yaml
173+
apiVersion: "autoscaling.k8s.io/v1"
174+
kind: VerticalPodAutoscaler
175+
metadata:
176+
name: example-vpa
177+
spec:
178+
targetRef:
179+
apiVersion: "apps/v1"
180+
kind: Deployment
181+
name: example
182+
updatePolicy:
183+
updateMode: "Recreate"
184+
startupBoost:
185+
cpu:
186+
value: "3"
187+
duration: 10s
188+
```
189+
190+
### Behavior
191+
192+
1. When a pod managed by the VPA is created, the VPA Admission Controller applies the CPU boost.
193+
2. The VPA Updater monitors the pod. Once the pod's condition is `Ready` and the `startupBoost.cpu.duration` has elapsed, it scales the CPU resources down in-place.
194+
3. The scale-down/unboost target is either the VPA recommendation (if VPA is enabled for the container) or the original CPU resources defined in the pod spec.
195+
196+
### Requirements
197+
198+
* Kubernetes 1.33+ with the `InPlacePodVerticalScaling` feature gate enabled.
199+
* VPA version 1.5.0+ with the `CPUStartupBoost` feature gate enabled.
200+
201+
### Configuration
202+
203+
Enable the feature by setting the `CPUStartupBoost` feature gate in the VPA admission-controller and updater components:
204+
205+
```bash
206+
--feature-gates=CPUStartupBoost=true
207+
```
208+
209+
The `startupBoost` field has the following sub-fields:
210+
* `cpu.type`: The type of boost. Can be `Factor` (default) to multiply the CPU, or `Quantity` to set a specific CPU value.
211+
* `cpu.value`: The magnitude of the boost. A multiplier (e.g., "2") for `Factor` type, or a resource quantity (e.g., "500m") for `Quantity` type.
212+
* `cpu.duration`: (Optional) How long to keep the boost active *after* the pod becomes `Ready`. Defaults to `0s`.

vertical-pod-autoscaler/docs/flags.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This document is auto-generated from the flag definitions in the VPA admission-c
1414
| `address` | string | ":8944" | The address to expose Prometheus metrics. |
1515
| `alsologtostderr` | | | log to standard error as well as files (no effect when -logtostderr=true) |
1616
| `client-ca-file` | string | "/etc/tls-certs/caCert.pem" | Path to CA PEM file. |
17-
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (ALPHA - default=false) |
17+
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>CPUStartupBoost=true\|false (ALPHA - default=false)<br>InPlaceOrRecreate=true\|false (ALPHA - default=false) |
1818
| `ignored-vpa-object-namespaces` | string | | A comma-separated list of namespaces to ignore when searching for VPA objects. Leave empty to avoid ignoring any namespaces. These namespaces will not be cleaned by the garbage collector. |
1919
| `kube-api-burst` | float | 100 | QPS burst limit when making requests to Kubernetes apiserver |
2020
| `kube-api-qps` | float | 50 | QPS limit when making requests to Kubernetes apiserver |
@@ -144,7 +144,7 @@ This document is auto-generated from the flag definitions in the VPA updater cod
144144
| `eviction-rate-burst` | int | 1 | Burst of pods that can be evicted. |
145145
| `eviction-rate-limit` | float | | Number of pods that can be evicted per seconds. A rate limit set to 0 or -1 will disable<br>the rate limiter. (default -1) |
146146
| `eviction-tolerance` | float | 0.5 | Fraction of replica count that can be evicted for update, if more than one pod can be evicted. |
147-
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>InPlaceOrRecreate=true\|false (ALPHA - default=false) |
147+
| `feature-gates` | mapStringBool | | A set of key=value pairs that describe feature gates for alpha/experimental features. Options are:<br>AllAlpha=true\|false (ALPHA - default=false)<br>AllBeta=true\|false (BETA - default=false)<br>CPUStartupBoost=true\|false (ALPHA - default=false)<br>InPlaceOrRecreate=true\|false (ALPHA - default=false) |
148148
| `ignored-vpa-object-namespaces` | string | | A comma-separated list of namespaces to ignore when searching for VPA objects. Leave empty to avoid ignoring any namespaces. These namespaces will not be cleaned by the garbage collector. |
149149
| `in-recommendation-bounds-eviction-lifetime-threshold` | | 12h0m0s | duration Pods that live for at least that long can be evicted even if their request is within the [MinRecommended...MaxRecommended] range |
150150
| `kube-api-burst` | float | 100 | QPS burst limit when making requests to Kubernetes apiserver |

vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/handler.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,16 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error {
163163
return fmt.Errorf("controlledValues shouldn't be specified if container scaling mode is off")
164164
}
165165
}
166+
if err := validateStartupBoost(policy.StartupBoost, isCreate); err != nil {
167+
return fmt.Errorf("invalid startupBoost in container %s: %v", policy.ContainerName, err)
168+
}
166169
}
167170
}
168171

172+
if err := validateStartupBoost(vpa.Spec.StartupBoost, isCreate); err != nil {
173+
return fmt.Errorf("invalid startupBoost: %v", err)
174+
}
175+
169176
if isCreate && vpa.Spec.TargetRef == nil {
170177
return fmt.Errorf("targetRef is required. If you're using v1beta1 version of the API, please migrate to v1")
171178
}
@@ -177,6 +184,48 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error {
177184
return nil
178185
}
179186

187+
func validateStartupBoost(startupBoost *vpa_types.StartupBoost, isCreate bool) error {
188+
if startupBoost == nil {
189+
return nil
190+
}
191+
192+
if !features.Enabled(features.CPUStartupBoost) && isCreate {
193+
return fmt.Errorf("in order to use startupBoost, you must enable feature gate %s in the admission-controller args", features.CPUStartupBoost)
194+
}
195+
196+
cpuBoost := startupBoost.CPU
197+
if cpuBoost == nil {
198+
return nil
199+
}
200+
boostType := cpuBoost.Type
201+
if boostType == nil {
202+
// Default to Factor when type is not specified.
203+
defaultType := vpa_types.FactorStartupBoostType
204+
boostType = &defaultType
205+
}
206+
207+
if *boostType != vpa_types.FactorStartupBoostType && *boostType != vpa_types.QuantityStartupBoostType {
208+
return fmt.Errorf("unexpected StartupBoost.CPU.Type value %s", *boostType)
209+
}
210+
211+
if *boostType == vpa_types.FactorStartupBoostType {
212+
if cpuBoost.Factor == nil {
213+
return fmt.Errorf("StartupBoost.CPU.Factor is required when Type is Factor")
214+
}
215+
if *cpuBoost.Factor < 1 {
216+
return fmt.Errorf("invalid StartupBoost.CPU.Factor: must be >= 1 for Type Factor")
217+
}
218+
} else if *boostType == vpa_types.QuantityStartupBoostType {
219+
if cpuBoost.Quantity == nil {
220+
return fmt.Errorf("StartupBoost.CPU.Quantity is required when Type is Quantity")
221+
}
222+
if err := validateCPUResolution(*cpuBoost.Quantity); err != nil {
223+
return fmt.Errorf("invalid StartupBoost.CPU.Quantity: %v", err)
224+
}
225+
}
226+
return nil
227+
}
228+
180229
func validateResourceResolution(name corev1.ResourceName, val apires.Quantity) error {
181230
switch name {
182231
case corev1.ResourceCPU:

0 commit comments

Comments
 (0)