A StorageClass defines how Kubernetes dynamically provisions storage volumes. Instead of manually creating PersistentVolumes, administrators create StorageClasses and allow PersistentVolumeClaims (PVCs) to automatically request storage from the underlying provider.
| Element | Required / Optional | Description | Example Syntax |
|---|---|---|---|
| apiVersion | Required | Specifies the Kubernetes API group and version for StorageClass resources. |
|
| kind | Required | Defines the Kubernetes resource type. |
|
| metadata.name | Required | Name of the StorageClass that application teams will reference inside their PVC manifests. |
|
| provisioner | Required | Specifies the storage plugin or CSI driver responsible for physically creating disks. |
|
| parameters | Optional (Highly Recommended) | Vendor-specific configuration settings such as storage type, performance profile, IOPS limits, throughput, encryption settings, or filesystem choices. |
|
| volumeBindingMode | Optional (Recommended) | Controls when storage volumes are created and bound to claims. WaitForFirstConsumer is commonly preferred because it allows Kubernetes to choose storage in the same availability zone as the scheduled Pod. |
|
| reclaimPolicy | Optional | Determines what happens to dynamically created storage when the PVC is deleted. Delete removes the underlying disk, while Retain preserves it for manual recovery. |
|
| allowVolumeExpansion | Optional | Allows existing PersistentVolumeClaims to grow in size without deleting and recreating them. |
|
Best Practice: For cloud environments, use
volumeBindingMode: WaitForFirstConsumer and
allowVolumeExpansion: true. These settings improve scheduling
flexibility and allow storage growth without disrupting applications.
No comments:
Post a Comment