Traditional Volume Configuration
Previously, storage details were embedded directly into the pod specification file. For example:Centralized Storage with Persistent Volumes
Persistent volumes solve these challenges by separating storage configuration from the pod definitions. Cluster administrators create a pool of storage resources, and users claim storage via Persistent Volume Claims (PVCs). This model simplifies management and reduces redundancy across the environment.
- Administrators manage storage centrally.
- Users claim storage as needed without repetitive configuration.
- Global changes and updates become easier to implement.
Creating a Persistent Volume
In this section, we create a persistent volume using a YAML template. Begin by updating the API version, setting the kind to PersistentVolume, and naming the volume (e.g., PV-01). Within the spec section, include:- Access Modes: Determines how a volume can be mounted (e.g., ReadOnlyMany, ReadWriteOnce, ReadWriteMany).
- Capacity: Specifies the allocated storage size (1Gi in this example).
- Volume Type: Here, we use a host path to utilize local node storage.
While using a hostPath is useful for demonstration purposes, it is not recommended for production environments. Always opt for a supported production-ready storage solution.