CSI Architecture

A cloud disk or a Ceph volume gets mounted into a Pod, though Kubernetes itself ships no driver for either. Who does the real work, from creating the disk to mounting it, and how does it talk to the cluster?

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

CSI Architecture diagram: CSI driver architecture

CSI Architecture, step by step

  1. The control plane deals only in objects, such as a PVC, a PersistentVolume or a VolumeAttachment, and by design has no idea how any particular disk is made or attached. So one Kubernetes can talk to dozens of storage backends it was never taught about.

    Play from step 1
  2. The controller plugin runs as a Deployment or StatefulSet with the sidecars the driver uses. They are optional but recommended. Each watches one object kind (provisioner for claims, attacher for attachments, resizer for resizes, snapshotter for snapshots), and all call one driver.

    Play from step 2
  3. Follow one sidecar. The external-provisioner picks up a Pending PVC whose storage-provisioner annotation (set once the claim needs a new volume) names the driver of this sidecar, and turns that PVC into a gRPC call, CreateVolume. The driver, not the sidecar, speaks to the cloud API and asks it for a real disk.

    Play from step 3
  4. The other half, the node plugin, is a DaemonSet, so a copy runs on each eligible Node. The node-driver-registrar sidecar of each copy leaves a socket where Kubelet looks for plugins and answers Kubelet with driver name and socket path. Kubelet then sends this plugin mount requests for this driver.

    Play from step 4
  5. Kubelet never mounts a vendor filesystem itself but calls NodePublishVolume (after NodeStageVolume if the driver stages), and only the node plugin mounts that filesystem for a Pod. The runtime binds that mount into the container, and the app writes through this bind. No mount a Pod uses comes from the controller plugin.

    Play from step 5
  6. On the controller side the sidecars are the bridge. The control plane writes plain objects and runs no vendor driver. The sidecars translate the objects into gRPC calls, the driver runs them, and the node plugin does the privileged work, like the mount. Another driver fits behind the same object kinds.

    Play from step 6

Sources