Provisioning NFS PVCs
Provisioning Network File System (NFS) Persistent Volume Claims (PVCs) involves setting up storage that can be simultaneously accessed in read-write mode by multiple nodes or pods within a Kubernetes cluster.
Block storage, such as Persistent Volumes (PVs) in Kubernetes, is generally not designed to be mounted to multiple pods simultaneously. Block storage devices are designed for exclusive access. When multiple pods attempt to read from and write to the same block storage simultaneously, it can cause conflicts.
OpenEBS Replicated PV Mayastor supports ReadWriteMany (RWX) volumes by exposing regular Replicated PV Mayastor volumes via NFSv4 servers as a pod.
#
ConceptReplicated PV Mayastor uses the NFS server as a deployment with the NFS CSI driver. This provides PVCs in RWX mode so that multiple applications can access the data in a shared fashion. Replicated PV Mayastor volumes are used as persistent backend storage for these NFS servers to provide a scalable and manageable RWX shared storage solution.
#
Requirements#
NFS Server as a PodNFS volumes can be mounted as a PersistentVolume
in Kubernetes pods. It is also possible to pre-populate a NFS volume and pods may share a NFS volume. It is beneficial when certain files must be writable between multiple pods.
#
NFS CSI DriverAn NFS CSI driver is a specific type of Container Storage Interface (CSI) driver that enables container orchestration systems, like Kubernetes, to manage storage using the NFS. NFS (A distributed file system protocol) allows multiple machines to share directories over a network. The NFS CSI driver facilitates the use of NFS storage by providing the necessary interface for creating, mounting, and managing NFS volumes within a containerized environment, ensuring that applications running in containers can easily access and use NFS-based storage.
CSI plugin name: nfs.csi.k8s.io
. This driver requires an existing and already configured NFSv3 or NFSv4 server. It supports dynamic provisioning of Persistent Volumes via PVCs by creating a new sub-directory under the NFS server. This can be deployed using Helm. See NFS CSI driver for Kubernetes to install NFS CSI driver on a Kubernetes cluster.
#
Replicated PV MayastorReplicated PV Mayastor is a performance-optimised Container Native Storage (CNS) solution. The goal of OpenEBS is to extend Kubernetes with a declarative data plane, providing flexible persistent storage for stateful applications.
Make sure you have installed Replicated PV Mayastor before proceeding to the next step. See the Installing OpenEBS Documentation to install Replicated PV Mayastor using Helm.
#
Details of Setup#
Setting up a Single NFS ServerCreate a Replicated PV Mayastor Pool.
Create a Replicated PV Mayastor pool that satisfies the performance and availability requirements. See Replicated PV Mayastor Configuration Documentation for more details.
Example of a Replicated PV Mayastor Pool
Command
Output
Create a Replicated PV Mayastor Storage Class.
Create a storage class to point to the above created pool. Also, select the number of replicas and the default size of the volume. See Replicated PV Mayastor Configuration Documentation for more details.
Example of a Replicated PV Mayastor Storage Class
Command
Output
Create a namespace for deploying the NFS server.
Command
Output
Create a PVC with the desired storage for the NFS server using the Replicated PV Mayastor storage class.
Command
Output
- Use the following command to verify the PVC creation:
Command
Output
Deploy the NFS server.
- Deployment manifest
Deploy the NFS server using the following yaml file. Use a Kubernetes deployment to create the NFS server, containing a single pod running. Deploy the server with this deployment manifest.
- Deploy the NFS server using the above deployment manifest by using the following command:
Command
Output
- Use the following command to verify the NFS server deployment:
Command
Output
- Create a service object that provides a ClusterIP to access the NFS server by using the following command:
NFS Server Example:
nfs-server.nfs-server.svc.cluster.local
YAML
Command
Output
- Use the following command to verify the service object:
Command
Output
#
Setting up a NFS CSI DriverCreate a storage class.
- Edit the values.yaml to use the NFS server.
StorageClass Resource Example
- Create a new namespace for the NFS CSI Driver.
Command
Output
- Install NFS CSI Driver using helm.
Command
Output
- Verify the CSI NFS Driver pods status.
- Verify the pod status.
Command
Output
- Verify the storage class.
Command
Output
Command
Output
#
NFS PVC Creation- Create PVC with NFS CSI Driver Storage Class
nfs-csi
(that was created in the last step).
YAML
Command
Output
- Use the following command to verify the PVC:
Command
Output
- Deploy the application.
YAML
Command
Output