NFS Server CRD

NFS Server can be created and configured using the nfsservers.nfs.rook.io custom resource definition (CRD). Please refer to the user guide walk-through for complete instructions. This page will explain all the available configuration options on the NFS CRD.

Sample

The parameters to configure the NFS CRD are demonstrated in the example below which is followed by a table that explains the parameters in more detail.

Below is a very simple example that shows sharing a volume (which could be hostPath, cephFS, cephRBD, googlePD, EBS, etc.) using NFS, without any client or per export based configuration.

For a PersistentVolumeClaim named googlePD-claim, which has Read/Write permissions and no squashing, the NFS CRD instance would look like the following:

  1. apiVersion: nfs.rook.io/v1alpha1
  2. kind: NFSServer
  3. metadata:
  4. name: nfs-vol
  5. namespace: rook
  6. spec:
  7. replicas: 1
  8. exports:
  9. - name: nfs-share
  10. server:
  11. accessMode: ReadWrite
  12. squash: none
  13. persistentVolumeClaim:
  14. claimName: googlePD-claim

Settings

The table below explains in detail each configuration option that is available in the NFS CRD.

ParameterDescriptionDefault
replicasThe number of NFS daemon to start1
exportsParameters for creating an export<empty>
exports.nameName of the volume being shared<empty>
exports.serverNFS server configuration<empty>
exports.server.accessModeVolume access modes (Reading and Writing) for the share (Valid options are ReadOnly, ReadWrite and none)ReadWrite
exports.server.squashThis prevents root users connected remotely from having root privileges (valid options are none, rootId, root and all)none
exports.server.allowedClientsAccess configuration for clients that can consume the NFS volume<empty>
exports.server.allowedClients.nameName of the host/hosts<empty>
exports.server.allowedClients.clientsThe host or network to which the export is being shared. Valid entries for this field are host names, IP addresses, netgroups, and CIDR network addresses.<empty>
exports.server.allowedClients.accessModeReading and Writing permissions for the client (valid options are same as exports.server.accessMode)ReadWrite
exports.server.allowedClients.squashSquash option for the client (valid options are same as exports.server.squash)none
exports.persistentVolumeClaimThe PVC that will serve as the backing volume to be exported by the NFS server. Any PVC is allowed, such as host paths, CephFS, Ceph RBD, Google PD, Amazon EBS, etc..<empty>
exports.persistentVolumeClaim.claimNameName of the PVC<empty>

*note: if exports.server.allowedClients.accessMode and exports.server.allowedClients.squash options are specified, exports.server.accessMode and exports.server.squash are overridden respectively.

Description for volumes.allowedClients.squash valid options are:

  1. none (No user id squashing is performed)
  2. rootId (uid 0 and gid 0 are squashed to the anonymous uid and anonymous gid)
  3. root (uid 0 and gid of any value are squashed to the anonymous uid and anonymous gid)
  4. all (All users are squashed)

The volume that needs to be exported by NFS must be attached to NFS server pod via PVC. Examples of volume that can be attached are Host Path, AWS Elastic Block Store, GCE Persistent Disk, CephFS, RBD etc. The limitations of these volumes also apply while they are shared by NFS. The limitation and other details about these volumes can be found here.

Examples

This section contains some examples for more advanced scenarios and configuration options.

Single volume exported for access by multiple clients

This example shows how to share a volume with different options for different clients accessing the share. The EBS volume (represented by a PVC) will be exported by the NFS server for client access as /nfs-share (note that this PVC must already exist). The following client groups are allowed to access this share:

  • group1 with IP address 172.17.0.5 will be given Read Only access with the root user squashed.
  • group2 includes both the network range of 172.17.0.5/16 and a host named serverX. They will all be granted Read/Write permissions with no user squash.
  1. apiVersion: nfs.rook.io/v1alpha1
  2. kind: NFSServer
  3. metadata:
  4. name: nfs-vol
  5. namespace: rook
  6. spec:
  7. replicas: 1
  8. exports:
  9. - name: nfs-share
  10. server:
  11. allowedClients:
  12. - name: group1
  13. clients: 172.17.0.5
  14. accessMode: ReadOnly
  15. squash: root
  16. - name: group2
  17. clients:
  18. - 172.17.0.0/16
  19. - serverX
  20. accessMode: ReadWrite
  21. squash: none
  22. persistentVolumeClaim:
  23. claimName: ebs-claim

Multiple volumes

This section provides an example of how to share multiple volumes from one NFS server. These volumes can all be different types (e.g., Google PD and Ceph RBD). Below we will share an Amazon EBS volume as well as a CephFS volume, using differing configuration for the two:

  • The EBS volume is named share1 and is available for all clients with Read Only access and no squash.
  • The CephFS volume is named share2 and is available for all clients with Read/Write access and no squash.
  1. apiVersion: nfs.rook.io/v1alpha1
  2. kind: NFSServer
  3. metadata:
  4. name: nfs-multi-vol
  5. namespace: rook
  6. spec:
  7. replicas: 1
  8. exports:
  9. - name: share1
  10. server:
  11. allowedClients:
  12. - name: ebs-host
  13. clients: all
  14. accessMode: ReadOnly
  15. squash: none
  16. persistentVolumeClaim:
  17. claimName: ebs-claim
  18. - name: share2
  19. server:
  20. allowedClients:
  21. - name: ceph-host
  22. clients: all
  23. accessMode: ReadWrite
  24. squash: none
  25. persistentVolumeClaim:
  26. claimName: cephfs-claim