Skip to content

CSI

Introduction

Container Storage Interface (CSI) is an industry standard that enables storage vendors to develop plugins for container orchestrators like Kubernetes without touching the core orchestrator code. It defines a common API between container orchestrators and storage providers.

Key Concepts

  • Volume — A unit of storage made available to a container workload.
  • CSI Driver — A storage plugin that implements the CSI specification (Node, Controller, and Identity services).
  • PersistentVolume (PV) — A piece of storage provisioned by the CSI driver.
  • PersistentVolumeClaim (PVC) — A request for storage by a user/pod.
  • StorageClass — Defines a class of storage with a specific CSI driver and parameters.
  • VolumeSnapshot — A point-in-time copy of a volume.

Architecture

text
┌────────────────────────────────────────────────────┐
│                 Kubernetes Cluster                  │
│                                                    │
│  ┌─────────────┐         ┌───────────────────┐    │
│  │  kube-       │         │  CSI Driver       │    │
│  │  controller- │────────▶│  Controller Plugin │    │
│  │  manager     │         │  (CreateVolume,    │    │
│  └─────────────┘         │   DeleteVolume,    │    │
│                           │   Snapshot...)     │    │
│  ┌─────────────┐         ├───────────────────┤    │
│  │  kubelet     │────────▶│  Node Plugin       │    │
│  │  (per node)  │         │  (NodeStageVolume, │    │
│  └─────────────┘         │   NodePublish...)  │    │
│                           └────────┬──────────┘    │
│                                    │               │
│                           ┌────────▼──────────┐    │
│                           │  Storage Backend  │    │
│                           │  (AWS EBS, GCE PD,│    │
│                           │   Ceph, NFS...)   │    │
│                           └───────────────────┘    │
└────────────────────────────────────────────────────┘

CSI Sidecar Containers

Kubernetes provides standard sidecar containers that communicate with CSI drivers:

SidecarDescription
external-provisionerWatches PVCs and triggers CreateVolume / DeleteVolume
external-attacherWatches VolumeAttachment and triggers ControllerPublish / Unpublish
external-snapshotterWatches VolumeSnapshot and triggers CreateSnapshot
external-resizerWatches PVCs for size changes and triggers ControllerExpandVolume
node-driver-registrarRegisters the CSI driver with kubelet
livenessprobeMonitors CSI driver health

StorageClass Example

yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast-ssd
provisioner: ebs.csi.aws.com
parameters:
  type: gp3
  iops: "5000"
  throughput: "250"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true

PVC Example

yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-data
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: fast-ssd
  resources:
    requests:
      storage: 50Gi

Common CSI Drivers

DriverStorage Backend
aws-ebs-csi-driverAmazon EBS
gcp-pd-csi-driverGoogle Persistent Disk
azuredisk-csi-driverAzure Managed Disks
csi-driver-nfsNFS
rook-ceph-csiCeph (via Rook)
minio-csiMinIO Object Storage
longhorn-csiLonghorn Distributed Storage

Reference:

  1. CSI Specification
  2. Kubernetes CSI Developer Docs
  3. CSI Drivers List

Power by VitePress & Vue