Traditionally we have shared storage, across the nodes using NFS/iSCSCI at the operating system level. Kubernetes comes with concept of PV and PVC, lets discuss this briefly before we start deploying NFS and associate with our Kubernetes cluster.
Containers are immutable , when container shutdown all the data is lost. This behaviour may not be suitable for some applications like database where application needs to share the data with other applications or preserve data. Kubernetes provides a reliable persistent storage mechanism for containers. It is based on Persistent Volume (PV). To make the things simple node is a compute resource used by the cluster, a PV is a storage resource
Administrators provides PV’s and it has attributes like file size, file system,volume ID and name.POD’s request a volume by issuing persistent volume claim (PVC).
In my lab set up I have following Kubernetes nodes running and I am deploying NFS and intergating with Kubernetes.
|IP Address||FQDN||Node Name|
Files for NFS Configuration
- /etc/exports : It’s a main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server end.
- /etc/fstab : To mount a NFS directory on your system across the reboots, we need to make an entry in /etc/fstab.
- /etc/sysconfig/nfs : Configuration file of NFS to control on which port rpc and other services are listening.
I have disabled the selinux security and disabled the firewall on the nfs server and updated entire system before starting the deployment
Install NFS packages on our NFS Server
Start and enable the service
My setup encountered some challenges in accessing the nfs, so I changed the configuration from secure to insecure in the export file.
“Showmount” is for verification, Run this command on all the nodes. You need to install this command using “yum install showmount”. On all the nodes issue this command to verify mounting of NFS mounting
mount -t nfs 192.168.0.67:/k8snfs /mnt
Let us Configure NFS based Persistent Volume in Kubernetes
Configure PV (Persistent Volume)
To create an NFS based persistent volume in K8s, create the yaml file on master node with the mount path and the ip address of the NFS server
create persistent volume
Configure Persistent Volume Claim
Verify the PVC
Deploy nginx with following YAML.
That’s it, you are done. In the next section we will cover HELM.
Please provide your feedback in comment section.