Static vs dynamic PV provisioning¶
In Kubernetes, Static vs Dynamic PV Provisioning refers to the two methods by which PersistentVolumes (PVs) are created and supplied to fulfill requests made by [[PersistentVolumeClaims]] (PVC).^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
Static Provisioning¶
In static provisioning, the cluster administrator manually creates and configures the PersistentVolumes.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
Under this model, the storage resources are declared in advance. When a user creates a PVC, the system searches for an existing PV that matches the claim's specific requirements (such as size, access modes, and storage class).^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] If a match is found, the two are bound; if not, the PVC remains in a pending state indefinitely until a suitable PV is manually added to the cluster.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
Dynamic Provisioning¶
Dynamic Provisioning delegates the creation of storage to the cluster itself, removing the need for manual administrator intervention for each new volume.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
This process is driven by the StorageClass resource.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] When a PVC specifies a storageClassName that has been pre-configured by the administrator, Kubernetes automatically provisions a new PersistentVolumes based on that class's parameters (e.g., creating a new disk on a cloud provider).^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
- Default Behavior: If a PVC does not specify a class, the cluster's default
StorageClassis used.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] - Disabling Dynamic Provisioning: To prevent automatic provisioning and force a match against statically created volumes only, a PVC can explicitly set its storage class to an empty string (
"").^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]
Key Differences¶
| Feature | Static Provisioning | Dynamic Provisioning |
|---|---|---|
| Creation Method | Pre-created by administrator.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] | Created automatically on demand.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] |
| Configuration | Manual definition of PV resources. | Relies on StorageClass definitions.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] |
| Failure State | PVC stays Pending if no matching PV exists.^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md] |
Fails if no matching StorageClass exists or the provisioner fails. |
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day20__README.md]