Heuristic:A5c ai Babysitter Storage Class Default Omission
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Debugging |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Omit `storageClassName` from PVC manifests to let them bind against the cluster's default StorageClass, rather than hardcoding a value that breaks on cloud-managed Kubernetes.
Description
Hardcoding `storageClassName: 'standard'` in workspace PVC manifests broke AKS (Azure Kubernetes Service), whose default StorageClass is `managed-csi` (or `default`). The PVC never bound (`"storageclass 'standard' not found"`) and the agent pod stayed Pending indefinitely. The fix omits `storageClassName` from the PVC manifest unless explicitly set via `volumeSpec.storageClassName` or the `KRADLE_WORKSPACE_STORAGE_CLASS` environment variable. When omitted, Kubernetes automatically binds the PVC against the cluster's default StorageClass, which works across minikube (`standard`), AKS (`managed-csi`), GKE (`standard`/`premium-rwo`), and EKS (`gp2`/`gp3`).
Usage
Use this heuristic when provisioning PersistentVolumeClaims for agent workspaces on any Kubernetes cluster. The symptom of the violation is a PVC stuck in `Pending` with the event `storageclass '<name>' not found`.
The Insight (Rule of Thumb)
- Action: Set `storageClassName` to `undefined` (omit from manifest) unless explicitly overridden.
- Value: `const storageClassName = volumeSpec.storageClassName || process.env.KRADLE_WORKSPACE_STORAGE_CLASS || undefined;`
- Trade-off: You lose explicit control over which StorageClass is used. If a cluster has multiple StorageClasses without a clear default, the PVC may bind to an unexpected one. Use `KRADLE_WORKSPACE_STORAGE_CLASS` to override when needed.
- Compatibility: Works across minikube, AKS, GKE, and EKS. The PVC spec omits the field entirely when no override is set, falling back to cluster default.
Reasoning
Kubernetes StorageClasses are cluster-specific. A hardcoded `storageClassName` that works on minikube (`standard`) fails on AKS (`managed-csi`), GKE (`standard` or `premium-rwo`), or EKS (`gp2` or `gp3`). By omitting the field, Kubernetes uses the cluster's default StorageClass, which is always available and correct for the target environment. The escape hatch (`KRADLE_WORKSPACE_STORAGE_CLASS` env var) allows explicit overrides for clusters where the default is not the desired class.
Code Evidence
StorageClass omission from `packages/kradle/core/src/agent-workspace-controller.js:49-56`:
const pvcName = `kradle-ws-${workspaceName}`;
// Omit storageClassName unless explicitly set (or overridden via env) so the
// PVC binds against the cluster's DEFAULT StorageClass. Hardcoding 'standard'
// broke AKS (whose default is 'default'/'managed-csi') — the PVC never bound
// ("storageclass 'standard' not found") and the agent pod stayed Pending.
const storageClassName = volumeSpec.storageClassName
|| process.env.KRADLE_WORKSPACE_STORAGE_CLASS || undefined;
PVC manifest with conditional storageClassName from `packages/kradle/core/src/agent-workspace-controller.js:58-68`:
const workspace = createResource('KradleWorkspace', { name: workspaceName, namespace }, {
organizationRef,
repository,
volumeSpec: {
...(storageClassName ? { storageClassName } : {}),
capacity,
accessModes,
},
branch: branch || 'main',
pvcName,
});