NFS Server CRD
Rook allows exporting NFS shares of a CephFilesystem or CephObjectStore through the CephNFS custom resource definition. This will spin up a cluster of NFS Ganesha servers that coordinate with one another via shared RADOS objects. The servers will be configured for NFSv4.1+ access only, as serving earlier protocols can inhibit responsiveness after a server restart.
Due to a number of Ceph issues and changes, Rook officially only supports Ceph v16.2.7 or higher for CephNFS. If you are using an earlier version, upgrade your Ceph version following the advice given in Rook's v1.9 NFS docs.
server spec sets configuration for Rook-created NFS-Ganesha servers.
active: The number of active NFS servers. Rook supports creating more than one active NFS server, but cannot guarantee high availability. For values greater than 1, see the known issue below.
placement: Kubernetes placement restrictions to apply to NFS server Pod(s). This is similar to placement defined for daemons configured by the CephCluster CRD.
annotations: Kubernetes annotations to apply to NFS server Pod(s)
labels: Kubernetes labels to apply to NFS server Pod(s)
resources: Kubernetes resource requests and limits to set on NFS server Pod(s)
priorityClassName: Set priority class name for the NFS server Pod(s)
logLevel: The log level that NFS-Ganesha servers should output. Default value: NIV_INFO Supported values: NIV_NULL | NIV_FATAL | NIV_MAJ | NIV_CRIT | NIV_WARN | NIV_EVENT | NIV_INFO | NIV_DEBUG | NIV_MID_DEBUG | NIV_FULL_DEBUG | NB_LOG_LEVEL
When a CephNFS is first created, all NFS daemons within the CephNFS cluster will share a configuration with no exports defined.
Using the Ceph Dashboard¶
Using the Ceph CLI¶
The Ceph CLI can be used from the Rook toolbox pod to create and manage NFS exports. To do so, first ensure the necessary Ceph mgr modules are enabled, if necessary, and that the Ceph orchestrator backend is set to Rook.
Enable the Ceph orchestrator if necessary¶
- Required for Ceph v16.2.7 and below
- Optional for Ceph v16.2.8 and above
- Must be disabled for Ceph v17.2.0 due to a Ceph regression
Ceph's NFS CLI can create NFS exports that are backed by CephFS (a CephFilesystem) or Ceph Object Gateway (a CephObjectStore).
cluster-name in the Ceph NFS docs normally refers to the name of the NFS cluster, which is the CephNFS name in the Rook context.
For creating an NFS export for the CephNFS and CephFilesystem example manifests, the below command can be used. This creates an export for the
/test pseudo path.
The below command will list the current NFS exports for the example CephNFS cluster, which will give the output shown for the current example.
/test export's info can be listed as well. Notice from the example that only NFS protocol v4 via TCP is supported.
If you are done managing NFS exports and don't need the Ceph orchestrator module enabled for anything else, it may be preferable to disable the Rook and NFS mgr modules to free up a small amount of RAM in the Ceph mgr Pod.
Each CephNFS server has a unique Kubernetes Service. This is because NFS clients can't readily handle NFS failover. CephNFS services are named with the pattern
<id> is a unique letter ID (e.g., a, b, c, etc.) for a given NFS server. For example,
For each NFS client, choose an NFS service to use for the connection. With NFS v4, you can mount an export by its path using a mount command like below. You can mount all exports at once by omitting the export path and leaving the directory as just
Exposing the NFS server outside of the Kubernetes cluster¶
Use a LoadBalancer Service to expose an NFS server (and its exports) outside of the Kubernetes cluster. The Service's endpoint can be used as the NFS service address when mounting the export manually. We provide an example Service here:
Scaling the active server count¶
It is possible to scale the size of the cluster up or down by modifying the
spec.server.active field. Scaling the cluster size up can be done at will. Once the new server comes up, clients can be assigned to it immediately.
The CRD always eliminates the highest index servers first, in reverse order from how they were started. Scaling down the cluster requires that clients be migrated from servers that will be eliminated to others. That process is currently a manual one and should be performed before reducing the size of the cluster.
See the known issue below about setting this value greater than one.
server.active count greater than 1¶
- Active-active scale out does not work well with the NFS protocol. If one NFS server in a cluster is offline, other servers may block client requests until the offline server returns, which may not always happen due to the Kubernetes scheduler.
- Workaround: It is safest to run only a single NFS server, but we do not limit this if it benefits your use case.
- Ceph NFS management with the Rook mgr module enabled has a breaking regression with the Ceph Quincy v17.2.0 release.
Workaround: Leave Ceph's Rook orchestrator mgr module disabled. If you have enabled it, you must disable it using the snippet below from the toolbox.
All CephNFS daemons are configured using shared RADOS objects stored in a Ceph pool named
.nfs. Users can modify the configuration object for each CephNFS cluster if they wish to customize the configuration.
Changing configuration of the .nfs pool¶
By default, Rook creates the
.nfs pool with Ceph's default configuration. If you wish to change the configuration of this pool (for example to change its failure domain or replication factor), you can create a CephBlockPool with the
spec.name field set to
.nfs. This pool must be replicated and cannot be erasure coded.
deploy/examples/nfs.yaml contains a sample for reference.
Adding custom NFS-Ganesha config file changes¶
The NFS-Ganesha config file format for these objects is documented in the NFS-Ganesha project.
rados tool from the toolbox to interact with the configuration object. The below command will get you started by dumping the contents of the config object to stdout. The output will look something like the example shown if you have already created two exports as documented above. It is best not to modify any of the export objects created by Ceph so as not to cause errors with Ceph's export management.
rados ls and
rados put are other commands you will want to work with the other shared configuration objects.
Of note, it is possible to pre-populate the NFS configuration and export objects prior to creating CephNFS server clusters.
Ceph CSI NFS provisioner and NFS CSI driver¶
This feature is experimental, and we do not guarantee it is bug-free, nor will we support upgrades to future versions
In version 1.9.1, Rook is able to deploy the experimental NFS Ceph CSI driver. This requires Ceph CSI version 3.6.0 or above. We recommend Ceph v16.2.7 or above.
For this section, we will refer to Rook's deployment examples in the deploy/examples directory.
The Ceph CSI NFS provisioner and driver require additional RBAC to operate. Apply the
deploy/examples/csi/nfs/rbac.yaml manifest to deploy the additional resources.
Rook will only deploy the Ceph CSI NFS provisioner and driver components when the
ROOK_CSI_ENABLE_NFS config is set to
"true" in the
rook-ceph-operator-config configmap. Change the value in your manifest, or patch the resource as below.
The rook-ceph operator Helm chart will deploy the required RBAC and enable the driver components if
csi.nfs.enabled is set to
In order to create NFS exports via the CSI driver, you must first create a CephFilesystem to serve as the underlying storage for the exports, and you must create a CephNFS to run an NFS server that will expose the exports.
From the examples,
filesystem.yaml creates a CephFilesystem called
nfs.yaml creates an NFS server called
You may need to enable or disable the Ceph orchestrator. Follow the same steps documented above based on your Ceph version and desires.
You must also create a storage class. Ceph CSI is designed to support any arbitrary Ceph cluster, but we are focused here only on Ceph clusters deployed by Rook. Let's take a look at a portion of the example storage class found at
deploy/examples/csi/nfs/storageclass.yaml and break down how the values are determined.
provisioner: rook-ceph.nfs.csi.ceph.com because rook-ceph is the namespace where the CephCluster is installed
nfsCluster: my-nfs because this is the name of the CephNFS
server: rook-ceph-nfs-my-nfs-a because Rook creates this Kubernetes Service for the CephNFS named my-nfs
clusterID: rook-ceph because this is the namespace where the CephCluster is installed
fsName: myfs because this is the name of the CephFilesystem used to back the NFS exports
pool: myfs-replicated because myfs is the name of the CephFilesystem defined in
fsNameand because replicated is the name of a data pool defined in the CephFilesystem
csi.storage.k8s.io/*: note that these values are shared with the Ceph CSI CephFS provisioner
deploy/examples/csi/nfs/pvc.yaml for an example of how to create a PVC that will create an NFS export. The export will be created and a PV created for the PVC immediately, even without a Pod to mount the PVC. The
share parameter set on the resulting PV contains the share path (
share) which can be used as the export path when mounting the export manually.
deploy/examples/csi/nfs/pod.yaml for an example of how a PVC can be connected to an application pod.