How should Kubernetes update CSI node volume capacity dynamically?
Prompt and context
A CSI driver's volume-attachment capacity changes with cloud quotas and health. Design capacity reporting, scheduler consistency, failure protection, and upgrades for Kubernetes Mutable CSINode Allocatable. Explain the responsibility boundaries among the CSI driver, the node object, the scheduler, and attach failures.
What the interviewer evaluates
- Understanding that
CSINode.spec.drivers[].allocatable.countis a scheduling hint, not a real-time lock. - Explaining how a CSI driver updates capacity periodically or after an error.
- Handling stale values, concurrent updates, scheduler caches, and attach failures.
- Designing alerts, backoff, compatibility upgrades, and capacity recovery.
Clarifying questions to ask
- Does capacity change because of a cloud quota, driver health, or local node resources?
- What update delay and error are acceptable, and is conservative Pending behavior okay?
- Do the cluster and CSI driver versions support mutable allocatable values?
- After attach failure, should the system retry, move Pods, or freeze the node first?
30-second answer framework
Start with the object: the CSI driver writes usable volume capacity into CSINode, and the scheduler filters with it; because the value can lag, attach still performs the final check. The driver updates on a period or a clear capacity error, while controllers and the scheduler converge through watches. Rate-limit updates, protect ordering, and reduce capacity conservatively during uncertainty so an incorrect high value does not spread through the cluster.
Step-by-step deep dive
1. Responsibility chain and data model
Each node-and-driver pair has CSINode.spec.drivers[].allocatable.count. The CSI driver knows the storage backend's attachment limit and reports usable capacity; the scheduler treats it as pre-filter information. This field is not a distributed lock and cannot prevent races between scheduling decisions. The driver and controller must validate capacity again when a volume is actually created or attached.
2. Update triggers and consistency
The driver can refresh on the period configured through CSIDriver, or immediately after a clear capacity-exhaustion error. Use resource-version preconditions so an older driver cannot overwrite a newer value. Add a minimum interval and jitter to avoid turning cloud API noise into control-plane write amplification. The scheduler refreshes its cache through a watch and should make conservative decisions during a short inconsistency window.
3. Failure protection and recovery
When the driver cannot obtain quota or health, it must not report infinite capacity. It can retain the last known-good value with an expiry or reduce capacity to zero so new Pods remain Pending. Classify attach failures as capacity, permission, topology, or transient network errors; only capacity errors should update allocatable. Increase capacity gradually after recovery while watching attach success.
4. Upgrade, observe, and validate
Kubernetes v1.36 makes Mutable CSINode Allocatable stable. Before upgrading, validate the API Server, scheduler, kubelet, and CSI driver version matrix, then enable periodic updates on a small node canary. Monitor object-update delay, capacity-change frequency, Pending reasons, attach-failure classes, control-plane write QPS, and actual node usage. If signals degrade, pause updates, restore compatible settings, and keep the last trusted capacity.
Model answer
I would treat mutable allocatable as a scheduling hint, not a real-time lock. The CSI driver reports the node-and-driver attachment capacity in CSINode.spec.drivers[].allocatable.count, refreshing periodically or after a clear capacity-exhaustion error. The scheduler watches the object, but the driver still performs the final attach check.
Updates need rate limits, resource-version conditions, and jitter. If quota is unreliable, reduce capacity conservatively rather than writing an arbitrarily high value. Classify attach failures by capacity, permission, topology, and network; only capacity failures trigger an update. After v1.36 stabilizes the feature, canary nodes and watch update lag, Pending reasons, attach failures, write QPS, and actual usage. Pause updates and restore the last trusted value when signals degrade.
Common mistakes
- Treating allocatable as a contention-free real-time lock.
- Reducing capacity to zero for every attach failure and causing collateral Pending Pods.
- Letting a driver write
CSINodeat high frequency and amplifying control-plane load. - Reporting high capacity when quota lookup fails.
- Upgrading only API versions while ignoring CSI driver, scheduler, and kubelet compatibility.
Follow-up questions and responses
Follow-up 1: Why can attach fail after the scheduler saw enough capacity?
The field has propagation delay and concurrent consumers can spend the same quota. Scheduling filters lower the probability of failure; the CSI driver must validate again at attach and return a classified error.
Follow-up 2: How often should capacity refresh?
It depends on quota-change frequency, control-plane write budget, and the business tolerance for Pending Pods. Start conservatively, tune from update lag, failure rate, and write QPS, and use a backoff-triggered update after errors.
Follow-up 3: How do you stop an old driver overwriting new capacity?
Use resource-version conditional updates and a driver-version gate, limiting writes from old drivers during upgrades. Monitor writer identity, timestamps, and regressions; pause automatic expansion when a rollback is detected.