CSI Storage Capacity

The Scheduler can send a Pod to a Node with too little local storage for its volume, so creating the volume fails and scheduling starts over, at times on that Node again. How can the Scheduler see the free space first?

Play the animation 5 steps, animated, plays on a computer or a tablet

CSI Storage Capacity diagram: CSI storage capacity tracking

CSI Storage Capacity, step by step

  1. Without capacity tracking the Scheduler judges Nodes on CPU, memory, affinity and the rest, but not on free storage, and Node-1 wins. The Scheduler records Node-1 as the selected Node on the claim and waits for a volume there before it binds the Pod. Only 5Gi is free in the Node-1 pool, but nothing tells the Scheduler that.

    Play from step 1
  2. The external-provisioner calls CreateVolume for 20Gi on Node-1, and the driver answers ResourceExhausted because that pool has only 5Gi free. The driver reports topology, so the external-provisioner drops the selected Node and scheduling starts over. With the same inputs the choice can land on Node-1 again, and the Pod stays Pending.

    Play from step 2
  3. Now capacity tracking is on. The external-provisioner, started with --enable-capacity, calls GetCapacity for each topology segment and publishes one CSIStorageCapacity object per StorageClass and segment, by default only for WaitForFirstConsumer classes. A segment here is one Node: 5Gi for Node-1, 50Gi for Node-2.

    Play from step 3
  4. The Scheduler uses those objects because storageCapacity is true on the CSIDriver, the class binds WaitForFirstConsumer and the claim still needs a new volume. In its filter phase the Scheduler compares the 20Gi claim with maximumVolumeSize if the driver reports it, else capacity. 20Gi does not fit in 5Gi, so Node-1 is filtered out before scoring, leaving only Node-2.

    Play from step 4
  5. The Scheduler records Node-2 as the selected Node, the CSI controller creates the volume in the Node-2 pool, and the claim binds. Only then is the Pod bound to Node-2 and started. Room is found on the first try because the Scheduler checked capacity before it picked. However, capacity that changes after it was published can still force a retry.

    Play from step 5

Sources