CSI CephFS plugin

May 21, 2026 ยท View on GitHub

The CSI CephFS plugin is able to both provision new CephFS volumes and attach and mount existing ones to workloads.

Building

CSI plugin can be compiled in the form of a binary file or in the form of a Docker image. When compiled as a binary file, the result is stored in _output/ directory with the name cephcsi. When compiled as an image, it's stored in the local Docker image store with name cephcsi.

Building binary:

make cephcsi

Building Docker image:

make image-cephcsi

Configuration

Available command line arguments:

OptionDefault valueDescription
--endpointunix://tmp/csi.sockCSI endpoint, must be a UNIX socket
--drivernamecephfs.csi.ceph.comName of the driver (Kubernetes: provisioner field in StorageClass must correspond to this value)
--nodeidemptyThis node's ID
--typeemptyDriver type: [rbd/cephfs]. If the driver type is set to rbd it will act as a rbd plugin or if it's set to cephfs will act as a cephfs plugin
--instanceid"default"Unique ID distinguishing this instance of Ceph CSI among other instances, when sharing Ceph clusters across CSI instances for provisioning
--pluginpath"/var/lib/kubelet/plugins/"The location of cephcsi plugin on host
--pidlimit0Configure the PID limit in cgroups. The container runtime can restrict the number of processes/tasks which can cause problems while provisioning (or deleting) a large number of volumes. A value of -1 configures the limit to the maximum, 0 does not configure limits at all.
--metricsport8080TCP port for liveness metrics requests
--metricspath/metricsPath of prometheus endpoint where metrics will be available
--polltime60sTime interval in between each poll
--timeout3sProbe timeout in seconds
--clusternameemptyCluster name to set on subvolume
--forcecephkernelclientfalseForce enabling Ceph Kernel clients for mounting on kernels < 4.17
--kernelmountoptionsemptyComma separated string of mount options accepted by cephfs kernel mounter.
Note: These options will be replaced if kernelMountOptions are defined in the ceph-csi-config ConfigMap for the specific cluster.
--fusemountoptionsemptyComma separated string of mount options accepted by ceph-fuse mounter.
Note: These options will be replaced if fuseMountOptions are defined in the ceph-csi-config ConfigMap for the specific cluster.
--domainlabelsemptyKubernetes node labels to use as CSI domain labels for topology aware provisioning, should be a comma separated value (ex:= "failure-domain/region,failure-domain/zone")
--enable-read-affinityfalseenable read affinity
--setmetadatatrueDeprecated. Set metadata on volume. This flag will be removed in a future release.
--crush-location-labelsemptyKubernetes node labels that determine the CRUSH location the node belongs to, separated by ','.
Note: These labels will be replaced if crush location labels are defined in the ceph-csi-config ConfigMap for the specific cluster.
--radosnamespacecephfsemptyCephFS RadosNamespace used to store CSI specific objects and keys.
--logslowopinterval30sLog slow operations at the specified rate. Operation is considered slow if it outlives its deadline.
--feature-gatesemptyComma-separated list of feature gates (e.g., SlowGRPCRestart=false). Available gates: SlowGRPCRestart (default: true) โ€” restart the process when a unary gRPC call is stuck for more than 10 minutes.

NOTE: The parameter -forcecephkernelclient enables the Kernel CephFS mounter on kernels < 4.17. This is not recommended/supported if the kernel does not support quota.

Available environmental variables:

KUBERNETES_CONFIG_PATH: if you use k8s_configmap as metadata store, specify the path of your k8s config file (if not specified, the plugin will assume you're running it inside a k8s cluster and find the config itself).

Available volume parameters:

ParameterRequiredDescription
clusterIDyesString representing a Ceph cluster, must be unique across all Ceph clusters in use for provisioning, cannot be greater than 36 bytes in length, and should remain immutable for the lifetime of the Ceph cluster in use
fsNameyesCephFS filesystem name into which the volume shall be created
mounternoMount method to be used for this volume. Available options are kernel for Ceph kernel client and fuse for Ceph FUSE driver. Defaults to "default mounter".
poolnoCeph pool into which volume data shall be stored
volumeNamePrefixnoPrefix to use for naming subvolumes (defaults to csi-vol-).
snapshotNamePrefixnoPrefix to use for naming snapshots (defaults to csi-snap-)
backingSnapshotnoBoolean value. The PVC shall be backed by the CephFS snapshot specified in its data source. pool parameter must not be specified. (defaults to true)
kernelMountOptionsnoComma separated string of mount options accepted by cephfs kernel mounter, by default no options are passed. Check man mount.ceph for options.
fuseMountOptionsnoComma separated string of mount options accepted by ceph-fuse mounter, by default no options are passed.
csi.storage.k8s.io/provisioner-secret-name, csi.storage.k8s.io/node-stage-secret-namefor KubernetesName of the Kubernetes Secret object containing Ceph client credentials. Both parameters should have the same value
csi.storage.k8s.io/provisioner-secret-namespace, csi.storage.k8s.io/node-stage-secret-namespacefor KubernetesNamespaces of the above Secret objects
encryptednodisabled by default, use "true" to enable fscrypt encryption on PVC and "false" to disable it. Do not change for existing storageclasses
encryptionKMSIDnorequired if encryption is enabled and a kms is used to store passphrases
extraDeploynoarray of extra objects to deploy with the release

NOTE: An accompanying CSI configuration file, needs to be provided to the running pods. Refer to Creating CSI configuration for more information.

NOTE: A suggested way to populate and retain uniqueness of the clusterID is to use the output of ceph fsid of the Ceph cluster to be used for provisioning.

Required secrets for provisioning: User credentials with access to an existing volume

  • userID: ID of a user client
  • userKey: key of a user client

Notes on volume size: when provisioning a new volume, max_bytes quota attribute for this volume will be set to the requested volume size (see Ceph quota documentation). A request for a zero-sized volume means no quota attribute will be set.

Deployment with Kubernetes

Requires Kubernetes 1.14+

Use the cephfs templates

Your Kubernetes cluster must allow privileged pods (i.e. --allow-privileged flag must be set to true for both the API server and the kubelet). Moreover, as stated in the mount propagation docs, the Docker daemon of the cluster nodes must allow shared mounts.

YAML manifests are located in deploy/cephfs/kubernetes.

Create CSIDriver object:

kubectl create -f csidriver.yaml

Deploy RBACs for sidecar containers and node plugins:

kubectl create -f csi-provisioner-rbac.yaml
kubectl create -f csi-nodeplugin-rbac.yaml

Those manifests deploy service accounts, cluster roles and cluster role bindings. These are shared for both RBD and CephFS CSI plugins, as they require the same permissions.

Deploy ConfigMap for CSI plugins:

kubectl create -f csi-config-map.yaml

The configmap deploys an empty CSI configuration that is mounted as a volume within the Ceph CSI plugin pods. To add a specific Ceph clusters configuration details, refer to Creating CSI configuration for more information.

Deploy Ceph configuration ConfigMap for CSI pods:

kubectl create -f ../../ceph-conf.yaml

Deploy prerequisites for CSI Snapshot:

If you intend to use the snapshot functionality in Kubernetes cluster, please refer to snap-clone.md

Deploy CSI sidecar containers:

kubectl create -f csi-cephfsplugin-provisioner.yaml

Deploys deployment of provision which includes external-provisioner ,external-attacher for CSI CephFS.

Deploy CSI CephFS driver:

kubectl create -f csi-cephfsplugin.yaml

Deploys a daemon set with two containers: CSI node-driver-registrar and the CSI CephFS driver.

NOTE: In case you want to use a different release version, replace canary with the release version in the provisioner and nodeplugin YAMLs.

# for stable functionality replace canary with latest release version
    image: quay.io/cephcsi/cephcsi:canary

Check the release version here.

Verifying the deployment in Kubernetes

After successfully completing the steps above, you should see output similar to this:

$ kubectl get all
NAME                                 READY     STATUS    RESTARTS   AGE
pod/csi-cephfsplugin-provisioner-0   4/4       Running   0          25s
pod/csi-cephfsplugin-rljcv           3/3       Running   0          24s

NAME                                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
service/csi-cephfsplugin-provisioner   ClusterIP   10.101.78.75     <none>        8080/TCP   26s
...

Once the CSI plugin configuration is updated with details from a Ceph cluster of choice, you can try deploying a demo pod from examples/cephfs using the instructions provided to test the deployment further.

Notes on volume deletion

Dynamically provisioned volumes are deleted by the driver, when requested to do so. Statically provisioned volumes, from plugin versions less than or equal to 1.0.0, are a no-op when a delete operation is performed against the same, and are expected to be deleted on the Ceph cluster by the user.

Deployment with Helm

The same requirements from the Kubernetes section apply here, i.e. Kubernetes version, privileged flag and shared mounts.

The Helm chart is located in charts/ceph-csi-cephfs.

Deploy Helm Chart:

See the Helm chart readme for installation instructions.

Read Affinity using crush locations for CephFS subvolumes

Ceph CSI supports mounting CephFS subvolumes with kernel mount options "read_from_replica=localize,crush_location=type1:value1|type2:value2" to allow serving reads from the most local OSD (according to OSD locations as defined in the CRUSH map).

This can be enabled by adding labels to Kubernetes nodes like "topology.io/region=east" and "topology.io/zone=east-zone1" and passing command line arguments "--enable-read-affinity=true" and "--crush-location-labels=topology.io/zone,topology.io/region" to Ceph CSI CephFS daemonset pod "csi-cephfsplugin" container, resulting in Ceph CSI adding "--options read_from_replica=localize,crush_location=zone:east-zone1|region:east" kernel mount options during cephfs mount operation. If enabled, this option will be added to all CephFS subvolumes mapped by Ceph CSI. Well known labels can be found here.

Note: Label values will have all its dots "." normalized with dashes "-" in order for it to work with ceph CRUSH map.

CephFS Volume Encryption

Requires fscrypt support in the Linux kernel and Ceph.

Key management is compatible with the fscrypt userspace tool. See the design doc Ceph Filesystem fscrypt Support for details.

In general the KMS configuration is the same as for RBD encryption and can even be shared.

However, not all KMS are supported in order to be compatible with fscrypt. In general KMS that either store secrets to use directly (Vault), or allow access to the plain password (Kubernetes Secrets) work.

CephFS PVC Provisioning

Requires subvolumegroup to be created before provisioning the PVC. If the subvolumegroup provided in ceph-csi-config ConfigMap is missing in the ceph cluster, the PVC creation will fail and will stay in Pending state.

Kubernetes ServiceAccount Based Volume Access

Ceph-CSI supports optionally restricting CephFS subvolume access to specific Kubernetes ServiceAccounts. When configured, only Pods running with one of the allowed ServiceAccounts can mount the subvolume. One or more ServiceAccounts can be specified as a comma-separated list. This feature uses CephFS subvolume metadata to store the restriction and the CSI podInfoOnMount mechanism to identify the Pod's ServiceAccount during mount.

How it works

  1. A storage admin sets the .cephfs.csi.ceph.com/serviceaccount metadata on a CephFS subvolume to specify the allowed ServiceAccount name(s) as a comma-separated list.
  2. During ControllerPublishVolume, Ceph-CSI reads this metadata and passes it to the node via publish context.
  3. During NodePublishVolume, Ceph-CSI splits the comma-separated value and checks whether the Pod's ServiceAccount (provided via volume context by Kubelet) matches any entry.
  4. If the ServiceAccount was set in metadata and does not match any of the allowed ServiceAccounts, the mount is rejected with a PermissionDenied error.

Prerequisites

The podInfoOnMount field must be set to true in the CSIDriver spec so that Kubelet passes Pod information (including ServiceAccount name) in the volume context during NodePublishVolume. Without this, the restriction cannot be enforced and all mounts are allowed.

This feature requires controller-publish-secret set in storageclass for newer PVCs. For existing PVCs, the workaround mentioned here can be used.

Setting the restriction on a CephFS subvolume

Use the ceph fs subvolume metadata set command to set the allowed ServiceAccount(s). Multiple ServiceAccounts can be specified as a comma-separated list:

ceph fs subvolume metadata set \
  <filesystem> <subvolume> --group_name=<group> \
  .cephfs.csi.ceph.com/serviceaccount \
  <service-account-name>[,<service-account-name>...]

For example, to restrict a subvolume to the my-app-sa ServiceAccount:

ceph fs subvolume metadata set myfs \
  csi-vol-abc123 --group_name=csi \
  .cephfs.csi.ceph.com/serviceaccount my-app-sa

To allow multiple ServiceAccounts:

ceph fs subvolume metadata set myfs \
  csi-vol-abc123 --group_name=csi \
  .cephfs.csi.ceph.com/serviceaccount \
  my-app-sa,my-worker-sa

Removing the restriction

To remove the restriction and allow any ServiceAccount to mount the subvolume:

ceph fs subvolume metadata rm <filesystem> <subvolume> --group_name=<group> \
  .cephfs.csi.ceph.com/serviceaccount

All the Pods using the PVC should be scaled down completely and then scaled up for removing the restriction after removing metadata from the subvolume.