Kube Startup CPU Boost is a controller that increases CPU resource requests and limits during Kubernetes workload startup time
Kube Startup CPU Boost is a controller that increases CPU resource requests and limits during Kubernetes workload startup time
Kube Startup CPU Boost is a controller that increases CPU resource requests and limits during a Kubernetes workload's startup time. Once the workload is up and running, the resources are set back to their original values.
Note: This is not an officially supported Google product.
The primary use cases for Kube Startup CPU Boost are workloads that require extra CPU resources during the startup phase — typically JVM-based applications.
Kube Startup CPU Boost leverages the In-place Resource Resize for Kubernetes Pods feature introduced in Kubernetes 1.27. It allows reverting a workload's CPU resource requests and limits back to their original values without the need to recreate the Pods.
The increase in resources is achieved via a Mutating Admission Webhook. When configured, the webhook also removes CPU resource limits if present. The original resource values are restored by the operator after a given period of time or when a Pod condition is met.
[!WARNING] While kube-startup-cpu-boost significantly reduces container cold-start times, dynamically mutating pod resources at runtime can introduce unintended side effects in specific environments. Please read Side Effects for more details.
InPlacePodVerticalScaling feature gate.kubectl apply -f https://github.com/google/kube-startup-cpu-boost/releases/download/v0.21.1/manifests.yamlThe Kube Startup CPU Boost components run in the kube-startup-cpu-boost-system namespace.
You can use Kustomize to install Kube Startup CPU Boost with your own kustomization file.
cat kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/google/kube-startup-cpu-boost?ref=v0.21.1
EOF
kubectl kustomize | kubectl apply -f -Helm installation uses the self-hosted Helm chart repo kube-startup-cpu-boost.
helm repo add kube-startup-cpu-boost https://google.github.io/kube-startup-cpu-boost
helm repo update
helm install --create-namespace -n kube-startup-cpu-boost-system kube-startup-cpu-boost kube-startup-cpu-boost/kube-startup-cpu-boostEnsure that GKE is running version 1.33 or newer by using the GKE Rapid release channel.
gcloud container clusters create poc \
--release-channel rapid \
--region europe-central2Kube Startup CPU Boost supports multi-replica High Availability (HA) deployments. Running an HA
setup requires leader election to be enabled (LEADER_ELECTION=true), which is
enabled by default.
When installing via Helm, you can scale replicas and enable a PodDisruptionBudget to ensure at
least one replica remains available during cluster maintenance:
helm install \
--create-namespace -n kube-startup-cpu-boost-system \
kube-startup-cpu-boost kube-startup-cpu-boost/kube-startup-cpu-boost \
--set controllerManager.replicas=2 \
--set controllerManager.pdb.create=true \
--set controllerManager.pdb.minAvailable=1When installing via Kustomize from source (config/default), uncomment the HA component in
config/default/kustomization.yaml. This will increase number of replicas and
add PodDisruptionBudget.
Create a StartupCPUBoost object in your workload's namespace
apiVersion: autoscaling.x-k8s.io/v1alpha1
kind: StartupCPUBoost
metadata:
name: boost-001
namespace: demo
selector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values: ["spring-demo-app"]
spec:
resourcePolicy:
containerPolicies:
- matchContainers:
type: ExactName
value: spring-rest-jpa
percentageIncrease:
value: 50
durationPolicy:
podCondition:
type: Ready
status: "True"The above example will boost the CPU requests and limits of the spring-demo-app container in
Pods with the app.kubernetes.io/name=spring-demo-app label in the demo namespace.
The resources will be increased by 50% until the
Pod Condition
Ready becomes True.
Schedule your workloads and observe the results
Since v0.21.0, the operator can re-apply CPU boosts to existing Pods when their containers restart. This ensures that the boost is applied throughout the entire lifecycle of the workload.
The operator continues watching Pods even after CPU resources have been restored to their
original values. Container restarts are detected by observing container status changes and reacting
to the terminated state.
[!NOTE] This feature requires the
BOOST_ON_RESTARTenvironment variable to be set totrue.
Define the Pods that will be subject to a resource boost with a label selector.
spec:
selector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values: ["spring-rest-jpa"]Define the container(s) that will be subject to a resource boost with a container matcher.
The matcher can be defined with an exact container name or a regex pattern matching a container name using Go syntax.
spec:
resourcePolicy:
containerPolicies:
- containerName: spring-rest-jpa # legacy container name matcher
percentageIncrease:
value: 50
- matchContainers:
type: ExactName
value: spring-rest-jpa
percentageIncrease:
value: 50
- matchContainers:
type: RegexName
value: "spring-.+"
percentageIncrease:
value: 50Define the percentage increase for the target container(s). The CPU requests and limits of the selected container(s) will be increased by the given percentage value.
spec:
resourcePolicy:
containerPolicies:
- matchContainers:
type: ExactName
value: spring-rest-jpa
percentageIncrease:
value: 50Define the fixed resources for the target container(s). The CPU requests and limits of the selected container(s) will be set to the given values. Note that the specified requests and limits must be higher than the container's original values.
spec:
resourcePolicy:
containerPolicies:
- matchContainers:
type: ExactName
value: spring-rest-jpa
fixedResources:
requests: "1"
limits: "2"Define a fixed duration for which the resource boost will last, measured from the Pod's schedule time.
spec:
durationPolicy:
fixedDuration:
unit: Seconds
value: 60Define a Pod condition; the resource boost effect will remain active until the condition is met.
spec:
durationPolicy:
podCondition:
type: Ready
status: "True" Note: You can define multiple duration policies in a single boost (i.e. both
podConditionandfixedDuration). When combined, the boost is removed as soon as either condition is met.
The Kube Startup CPU Boost operator can be configured with environment variables.
| Variable | Type | Default | Description |
|---|---|---|---|
POD_NAMESPACE |
string |
kube-startup-cpu-boost-system |
Kube Startup CPU Boost operator namespace |
MGR_CHECK_INTERVAL |
int |
5 |
Duration in seconds between boost manager checks for time-based boost duration policies |
LEADER_ELECTION |
bool |
false |
Enables leader election for controller manager |
METRICS_PROBE_BIND_ADDR |
string |
:8080 |
Address the metrics endpoint binds to |
HEALTH_PROBE_BIND_ADDR |
string |
:8081 |
Address the health probe endpoint binds to |
SECURE_METRICS |
bool |
false |
Determines if the metrics endpoint is served securely |
ZAP_LOG_LEVEL |
int |
0 |
Log level for ZAP logger |
ZAP_DEVELOPMENT |
bool |
false |
Enables development mode for ZAP logger |
HTTP2 |
bool |
false |
Determines if the HTTP/2 protocol is used for webhook and metrics servers |
REMOVE_LIMITS |
bool |
false |
Enables the operator to remove container CPU limits during the boost period |
VALIDATE_FEATURE_ENABLED |
bool |
true |
Enables validation of the required feature gate on operator startup |
BOOST_ON_RESTART |
bool |
false |
Enables the boost on container restart feature |
Kube Startup CPU Boost exposes Prometheus metrics to monitor the health of the system and the status of Startup CPU Boosts.
| Metric name | Type | Description | Labels |
|---|---|---|---|
boost_configurations |
Gauge | Number of registered Kube Startup CPU Boost configurations | namespace: the namespace of the Kube Startup CPU Boost |
boost_containers_total |
Counter | Number of containers whose CPU resources were increased | namespace: the namespace of the container's Pod, boost: the name of the Kube Startup CPU Boost that increased the container's resources |
boost_containers_active |
Gauge | Number of containers whose CPU resources have not yet been reverted to their original values | namespace: the namespace of the container's Pod, boost: the name of the Kube Startup CPU Boost that increased the container's resources |
The following PodMonitoring example can be used to scrape Kube Startup CPU Boost metrics with Google Cloud Managed Service for Prometheus.
…While kube-startup-cpu-boost significantly reduces container cold-start times, dynamically
mutating pod resources at runtime can introduce unintended side effects in specific environments.
Many modern language runtimes, most notably the JVM, are container-aware and inspect Linux cgroups
at startup to determine available CPU shares and quotas. JVM uses this data to calculate the
ActiveProcessorCount, which governs the size of internal thread pools (e.g., Garbage Collection
threads, JIT compiler queues, and application worker poo
No open issues yet, or sync has not completed.