Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Going back to the end of the previous sub-chapter, we introduce the Rook storage provider. It is inserted between the hard disk of the VMs, always based on NFS, and the Kubernetes cluster. As said previously, NFS allows remote hosts to mount filesystems over a network and interact with those filesystems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers on the network. As a prerequisite, NFS client packages must be installed on all nodes (nfs-utils on CentOS), where Kubernetes might run pods with NFS mounted. However, the official guide can be found here.

Deploy NFS Operator

First deploy the Rook NFS operator using the following commands

...

Code Block
languagebash
titleVerify NFS server pod
collapsetrue
$ kubectl get pod -l app=rook-nfs -n rook-nfs
NAME         READY   STATUS    RESTARTS   AGE
rook-nfs-0   2/2     Running   0          43m

Accessing the Export

Since Rook version v1.0, Rook supports dynamic provisioning of NFS. This example will be showing how dynamic provisioning feature can be used for NFS. Once the NFS Operator and an instance of NFS Server is deployed, a SC similar to sc.yaml has to be created to dynamically provisioning volumes

Code Block
languagebash
titlesc.yaml
collapsetrue
$ k create -f sc.yaml
storageclass.storage.k8s.io/rook-nfs-share1 created

...

Info
titleParameters necessary for the SC

The SC need to have the following 3 parameters passed:

  • exportName: it tells the provisioner which export to use for provisioning the volumes;
  • nfsServerName: name of the NFS Server instance;
  • nfsServerNamespace: namespace where the NFS Server instance is running.

Once you have created the SC above, you can create a PVC that references it. The PVC will automatically (dynamically) create the respective PV.

Code Block
languagebash
titlepvc.yaml
collapsetrue
$ k create -f pvc.yaml
persistentvolumeclaim/rook-nfs-pv-claim created

...