Available in: Open/CE, Core, SE, SE+, Ultimate/EE
The module lifecycle stage: Generally available version
The module has requirements for installation
The csi-nfs module provides a CSI driver for managing NFS volumes in Kubernetes.
Use it to provision PersistentVolumes on an NFS server through the NFSStorageClass custom resources.
Main features
The csi-nfs module provides the following capabilities:
- Provision NFS-backed PersistentVolumes through the NFSStorageClass custom resource.
- Support RWO and RWX access modes, including RWX in Deckhouse Virtualization Platform.
- Restrict volume mounting to selected cluster nodes with the
workloadNodesparameter. - Support RPC-with-TLS mode (
tls/mtls) for connections to an NFS server (in commercial editions of DKP). - Clean volume data before PV deletion with the
volumeCleanupparameter (in commercial editions of DKP).
StorageClasses for the CSI driver nfs.csi.k8s.io are created only through the NFSStorageClass resource. Creating regular StorageClass resources for this CSI driver is prohibited.
System requirements and recommendations
Requirements
Before using the module, make sure the following requirements are met:
- Use stock kernels provided with supported distributions;
- Ensure that the NFS server is correctly configured and running:
- For DKP modules where StorageClass is used, it may be necessary to allow access to clients with root privileges. In Linux, this is implemented via the
no_root_squashoption. On other operating systems and storage systems, a similar setting may have a different name; - For virtual disk storage in the Deckhouse Virtualization Platform, the
no_root_squashoption is mandatory.
- For DKP modules where StorageClass is used, it may be necessary to allow access to clients with root privileges. In Linux, this is implemented via the
- To support RPC-with-TLS, the Linux kernel of the nodes must be built with the
CONFIG_TLSandCONFIG_NET_HANDSHAKEoptions.CONFIG_NET_HANDSHAKEis usually present in kernels 6.5 and later. The operating systems and kernels checked so far are listed in the FAQ. - Volume snapshots require the storage-foundation module. Without it, the rest of the module keeps working and no VolumeSnapshotClass is created.
Recommendations
For module pods to restart when the tlsParameters parameter is changed, make sure the pod-reloader module is enabled (enabled by default).
Limitations
Inline volumes
An inline CSI volume of nfs.csi.k8s.io (a csi volume in the pod spec) cannot mount an NFS server inside the cluster: when the server resolves to an address in the pod or service network of the cluster, the pod fails to start with PermissionDenied. The node plugin mounts from the node, and a server in the cluster that admits the nodes would otherwise give any pod that knows its address everything it exports. Mount such a server through a PersistentVolume of an NFSStorageClass. Inline volumes of servers outside the cluster work as before.
Creating volume snapshots
When creating snapshots of NFS volumes, it is important to understand their creation scheme and associated limitations. Avoid using snapshots in csi-nfs when possible:
- The CSI driver creates a snapshot at the NFS server level.
- For this, tar is used, which packages the volume contents, with all the limitations that may arise from this.
- Before creating a snapshot, be sure to stop the workload (pods) using the NFS volume.
- NFS does not ensure atomicity of operations at the file system level when creating a snapshot.
RPC-with-TLS mode limitations
The following limitations apply to RPC-with-TLS mode:
- For the
mtlssecurity policy, a node presents one client certificate on all its mounts: the one the module issues, or the one oftlsParameters.mtls. - A single NFS server cannot simultaneously operate in different security modes:
tls,mtls, and standard (non-TLS) mode. - The
tlshddaemon must not be running on the cluster nodes, otherwise it will conflict with the module daemon. To prevent conflicts when enabling TLS, the third-partytlshdis automatically stopped on the nodes and its autostart is disabled.
Quickstart
Run all commands on a machine that has administrator access to the Kubernetes API.
Enabling the module
Perform the following steps:
-
Enable the
csi-nfsmodule. This will result in the following actions across all cluster nodes:- registration of the CSI driver;
- launch of service pods for the
csi-nfscomponents.
-
Wait for the module to become
Ready:d8 k get module csi-nfs -w
Creating a StorageClass
To create a StorageClass, use the NFSStorageClass resource. Example:
d8 k apply -f - <<EOF
apiVersion: storage.deckhouse.io/v1alpha1
kind: NFSStorageClass
metadata:
name: nfs-storage-class
spec:
connection:
host: 10.223.187.3
share: /
nfsVersion: "4.1"
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
workloadNodes:
nodeSelector:
matchLabels:
storage: "true"
EOFCSI driver control pods are placed on cluster nodes according to the summarization of the workloadNodes parameters from all NFSStorageClass resources. If the workloadNodes parameter is missing in an NFSStorageClass, the workload will be placed on all nodes.
A directory <directory from share>/<PV name> will be created for each PV. To name the directories after the PVCs, use the spec.connection.subDir parameter, see the FAQ.