- Static provisioning: you create cloud disks ahead of time, then create the matching PersistentVolume (PV) objects and PersistentVolumeClaims (PVCs).
- Dynamic provisioning (StorageClass): Kubernetes creates the backing storage (cloud disk) automatically when a PVC requests a StorageClass; the PV is created and bound automatically.
Static provisioning
With static provisioning you manually create the backing disk in your cloud provider, then create a PV that references that disk, and finally create a PVC which binds to the PV. This process works but requires manual steps and coordination between cloud resources and Kubernetes manifests. Example: a manually-provisioned PV, a PVC that claims it, and a Pod that mounts the PVC:Dynamic provisioning with StorageClass
StorageClasses enable dynamic provisioning: when a PVC is created that references a StorageClass, Kubernetes uses the provisioner defined in that StorageClass to create backing storage on the cloud provider. The provisioner creates the disk, a PV object is created automatically, and the PVC binds to that PV. A minimal example StorageClass for Google Compute Engine using the legacy in-tree provisioner:storageClassName:
Note about provisioners and parameters
Different provisioners support different parameters and settings. For the legacy in-tree Google Persistent Disk provisioner you can choose disk type and replication mode, for example:
Example StorageClass using parameters for the in-tree GCE provisioner:
storageClassName and Kubernetes will dynamically provision the appropriate storage for you.
Consider modern clusters may use CSI drivers rather than the in-tree provisioners. For GKE, for example, the CSI provisioner name is
pd.csi.storage.gke.io. Check your cluster documentation and use the appropriate provisioner for production clusters.- Kubernetes Storage Concepts: https://kubernetes.io/docs/concepts/storage/
- Persistent Volumes: https://kubernetes.io/docs/concepts/storage/persistent-volumes/
- StorageClass documentation: https://kubernetes.io/docs/concepts/storage/storage-classes/
- GKE PD CSI Driver: https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/gce-pd-csi-driver