Using NFS storage for dynamic provisioning on kubernetes

This replaces Step 9 in this post and uses NFS instead of rook-ceph. If you have a Synology, you can use NFS. See this link to turn on NFS on the Synology, so that your kubernetes cluster can use it. Your NFS permission should include Allowing connections from non-privileged ports and Allow users to access mounted subfolders.

Step: 9) Setup NFS for storage

At this point, the cluster works but can only run stateless pods. The moment a pod is terminated, all the information with it is gone. To run stateful pods, for example StatefulSets, you need to have persistent storage. We’ll use NFS to provide that. This assumes you already have an NFS server set up, for example a NetApp, Synology, another NFS server, etc. First you need to install NFS client on every node.
:~$ sudo apt install nfs-common
Only on the master node, get the deployment file for nfs-client
draconpern@k8s-master:~$ wget
draconpern@k8s-master:~$ nano deployment.yaml
Change the server and path to your nfs mount. Change to your server and ‘/ifs/kubernetes’ to the nfs mount point on your server. For example..
            - name: NFS_SERVER
            - name: NFS_PATH
              value: /volume1/kubernetes
        - name: nfs-client-root
            path: /volume1/kubernetes
Apply the files
draconpern@k8s-master:~$ kubectl apply -f deployment.yaml
draconpern@k8s-master:~$ kubectl apply -f
draconpern@k8s-master:~$ wget
Add additional parameters in class.yaml
allowVolumeExpansion: "true"
reclaimPolicy: "Delete"
draconpern@k8s-master:~$ kubectl apply -f class.yaml
Unset rook-ceph as default and set nfs-client as the default
draconpern@k8s-master:~$ kubectl patch storageclass rook-ceph-block -p '{"metadata": {"annotations":{"":"false"}}}' 
draconpern@k8s-master:~$ kubectl patch storageclass managed-nfs-storage -p '{"metadata": {"annotations":{"":"true"}}}'
You should see an NFS connection to your server for every worker node you have. Continue to Step 13 on the original post.

Leave a Reply