Why autoscaling helps
- Sessions clone large repositories or produce build artifacts that outgrow the initial volume size.
- You want to keep
sessionVolume.initialSizesmall and pay only for storage that sessions actually use. See the Helm values reference for thesessionVolumeblock.
When to disable autoscaling
SetdiskAutoscale.enabled: false when your cluster cannot meet the prerequisites below, such as clusters that are not on EKS or that lack kubelet fine-grained authorization.
Prerequisites
- An EKS cluster with kubelet fine-grained authorization enabled. The control plane reads volume telemetry directly from each node’s kubelet, which must accept the control plane’s service account token.
- A StorageClass with
allowVolumeExpansion: truefor session volumes. Cake Agents skips expansion when the StorageClass does not allow it. rbac.enabled: truein the Helm chart. When autoscaling is enabled, the chart adds a ClusterRole that grants the control planegetonnodes/metricsandstorageclasses.
Configure with Helm values
Tune or disable autoscaling through thediskAutoscale block:
The chart maps these values to
SESSION_DISK_AUTOSCALE_* environment variables on the control plane. The control plane validates the configuration at startup and rejects invalid ratios, scale factors, storage quantities, and cron expressions.
Configure in the UI
You can also manage autoscaling from the organization settings:- Go to Settings → Organization → Data Plane.
- In the Autoscaling section, toggle Enabled on.
- Adjust the fields:
- Starting Volume Size — the size each new session volume starts at. Whole GiB values only, at least 1 Gi, and no larger than the max volume size. Applies to newly created sessions.
- High Watermark Ratio — usage fraction that triggers expansion. Must be between 0 and 1, exclusive.
- Max Volume Size — hard cap on any session volume’s size. Must be at least 1 Gi.
- Minimum Increment — smallest amount a volume grows in a single expansion.
- Scale Factor — multiplier applied to current usage to compute the new size. Must be greater than 1.
- Select Save.
Settings precedence
- Until you save autoscaling settings in the UI, the control plane uses the Helm values (
diskAutoscaleandsessionVolume.initialSize). - Once saved, UI settings replace the Helm values for the expansion policy and the starting volume size.
- Disabling autoscaling in the UI turns it off even when
diskAutoscale.enabledistruein Helm. - The reconciliation schedule (
cronExpression) always comes from Helm.
How expansion works
On each scheduled run, the control plane:- Lists running session pods and collects filesystem telemetry for each session volume from the node’s kubelet. Stale or malformed telemetry is rejected and logged, and that volume is skipped for the run.
- Compares used bytes against the volume’s current size. Volumes below
highWatermarkRatioare left unchanged. - Computes the new size as the larger of
current size + minIncrementandused bytes × scaleFactor, capped atmaxVolumeSize. - Patches the PersistentVolumeClaim with the new size. The storage provider then expands the underlying volume.
maxVolumeSize are never expanded further. Expansion is one-way: Cake Agents never shrinks a session volume.
Autoscaling inside sessions
Only files under/workspace are persistent in a session. /workspace is backed by the session volume and survives restarts. Files anywhere else, such as /tmp or /root, are ephemeral. The default agent prompt instructs agents to keep important files under /workspace.
When autoscaling is enabled, session agents also get a wait_for_volume_autoscale tool. If a write to /workspace fails because the disk is full, the agent can call this tool to wait for the volume to grow, then retry. The tool:
- Waits up to a configurable timeout (default 300 seconds, maximum 900) and returns as soon as
/workspacecapacity has grown. - Returns immediately with the reason and suggested next steps when the autoscaler decides not to expand, for example when usage is below the high watermark, the volume is at its maximum size, or the StorageClass does not allow expansion.
- Reports that autoscaling is disabled if it was turned off after the session started.