Kube Startup CPU Boost is a controller that increases CPU resource requests and limits during Kubernetes workload startup time
Kube Startup CPU Boost
Kube Startup CPU Boost is a controller that increases CPU resource requests and limits during Kubernetes workload startup time. Once the workload is up and running, the resources are set back to their original values.
Description
The primary use cases for Kube Startup CPU Boosts are workloads that require extra CPU resources during startup phase - typically JVM based applications.
The Kube Startup CPU Boost leverages In-place Resource Resize for Kubernetes Pods feature introduced in Kubernetes 1.27. It allows to revert workload's CPU resource requests and limits back to their original values without the need to recreate the Pods.
The increase of resources is achieved by Mutating Admission Webhook. By default, the webhook also removes CPU resource limits if present. The original resource values are set by operator after given period of time or when the POD condition is met.
Installation
Requires Kubernetes 1.27 on newer with InPlacePodVerticalScaling feature gate enabled.
To install the latest release of Kube Startup CPU Boost in your cluster, run the following command:
kubectl apply -f https://github.com/google/kube-startup-cpu-boost/releases/download/v0.10.0/manifests.yaml
The Kube Startup CPU Boost components run in kube-startup-cpu-boost-system namespace.
Install with Kustomize
You can use Kustomize to install the Kube Startup CPU Boost with your own kustomization file.
cat <<EOF > kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/google/kube-startup-cpu-boost?ref=v0.10.0
EOF
kubectl kustomize | kubectl apply -f -
Installation on Kind cluster
You can use KIND to get a local cluster for testing.
cat <<EOF > kind-poc-cluster.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: poc
nodes:
- role: control-plane
- role: worker
- role: worker
featureGates:
InPlacePodVerticalScaling: true
EOF
kind create cluster --config kind-poc-cluster.yaml
Installation on GKE cluster
You can use GKE Alpha cluster to run against the remote cluster.
gcloud container clusters create poc \
--enable-kubernetes-alpha \
--no-enable-autorepair \
--no-enable-autoupgrade \
--region europe-central2
Usage
Create
StartupCPUBoostobject in your workload's namespaceapiVersion: 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: - containerName: spring-demo-app percentageIncrease: value: 50 durationPolicy: podCondition: type: Ready status: "True"The above example will boost CPU requests and limits of a container
spring-demo-appin a PODs withapp.kubernetes.io/name=spring-demo-applabel indemonamespace. The resources will be increased by 50% until the POD ConditionReadybecomesTrue.Schedule your workloads and observe the results
Features
[Boost target] POD label selector
Define the PODs that will be subject for resource boost with a label selector.
spec:
selector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values: ["spring-rest-jpa"]
[Boost resources] percentage increase
Define the percentage increase for a target container(s). The CPU requests and limits of selected container(s) will be increase by the given percentage value.
spec:
containerPolicies:
- containerName: spring-rest-jpa
percentageIncrease:
value: 50
[Boost resources] fixed target
Define the fixed resources for a target container(s). The CPU requests and limits of selected container(s) will be set to the given values. Note that specified requests and limits have to be higher than the ones in the container.
spec:
containerPolicies:
- containerName: spring-rest-jpa
fixedResources:
requests: "1"
limits: "2"
[Boost duration] fixed time
Define the fixed amount of time, the resource boost effect will last for it since the POD creation.
spec:
durationPolicy:
fixedDuration:
unit: Seconds
value: 60
[Boost duration] POD condition
Define the POD condition, the resource boost effect will last until the condition is met.
spec:
durationPolicy:
podCondition:
type: Ready
status: "True"
Configuration
Kube Startup CPU Boost operator can be configured with environmental 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 policy |
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 | true | Enables operator to remove container CPU limits during the boost time |