Note the specific annotation after the provisioner key. This corresponds to the specific provisioner you would like to configure. Some options include:
Volume Plugin |
Provisioner |
AWS Elastic Block Store |
kubernetes.io/aws-ebs |
GCE Persistent Disk |
kubernetes.io/gce-pd |
Azure Files |
kubernetes.io/azure-file |
External NFS Server |
example.com/external-nfs |
In the manifest we defined above, a Storage Class is created for Kubernetes that specifies the kubernetes.io/aws-ebs provisioner and defines a StorageClass named gp2. The configuration in the parameters block depends on the specific provider and what options it offers. Different options translate to underlying storage performance, such as durability, number of input/output operations(IOPS), and throughput. The right choice depends on the requirements of a specific use case.
Note: If using a cloud external environment to create storage, such as with AWS EBS, the nodes hosting the Kubernetes cluster must have the necessary IAM permissions to attach and mount the EBS volumes. A similar approach should be taken with other cloud providers.
Persistent Volumes
Persistent volumes (PVs) are the actual storage volumes that can be accessed by applications running in a Kubernetes cluster. A storage administrator can provision them and then bind them to the applications that need them.
For example, an application running in a Kubernetes cluster might need a 10 GB volume to store its data. A storage administrator can create a 10 GB PV and bind it to the application using a PVC.
Persistent Volumes Claims
While a persistent volume represents the actual volume, an ongoing volume claim is a request for that volume. PVCs are called from pods requiring storage for their respective applications. In other words, a PVC is an additional abstraction layer over storage, and a pod cannot directly mount a PV. It needs a PVC.
When a PVC is requested, two of the most common options to include in the request are access mode and the requested capacity for the PVC. Access modes in a PVC specify how the claim can be accessed:
- ReadWriteOnce(RWO): Allows for read-write from one node(or as many podes from the same node) at a time
- ReadOnlyMany(ROX): Allows for read-only from many pods simultaneously
- ReadWriteMany(RWX): Allows for read-write from many pods simultaneously
- ReadWriteOncePod(RWOP): Allows for read-write from one specific pod only
A full example of the available options for PVC configuration can be seen in the official Kubernetes documentation.
Reclaim Policies
Reclaim policies determine what happens to the storage resources allocated to an application when the application is deleted or no longer requires the storage resources. The available options are Retain, Delete, and Recycle. For example, if an application is deleted, the following will happen to the underlying PV storage:
- Retain: This policy will keep the data in the Persistent Volume.
- Delete: This policy will delete the Persistent Volume.
- Recycle: A deprecated option that is no longer suggested for production usage, which โrm -rf /โs the contents of the Persistent Volume, making it available to be used for another PVC.
Default Storage Class
The default storage class is a Kubernetes concept that specifies the default storage class that will be used for applications that do not explicitly request a specific storage class in their persistent volume claim (PVC) manifest.