2019-06-20 19:30:40 +00:00
2018-07-31 09:31:12 +00:00
# CSI CephFS plugin
2019-02-07 09:58:38 +00:00
The CSI CephFS plugin is able to both provision new CephFS volumes
and attach and mount existing ones to workloads.
2018-07-31 09:31:12 +00:00
## Building
2019-05-24 11:03:33 +00:00
CSI plugin can be compiled in the form of a binary file or in the form
2019-02-18 04:47:31 +00:00
of a Docker image.
2019-02-07 09:58:38 +00:00
When compiled as a binary file, the result is stored in `_output/`
2019-05-08 04:27:13 +00:00
directory with the name `cephcsi` .
When compiled as an image, it's stored in the local Docker image store
2019-05-24 11:03:33 +00:00
with name `cephcsi` .
2018-07-31 09:31:12 +00:00
Building binary:
2019-02-06 06:25:52 +00:00
2018-07-31 09:31:12 +00:00
```bash
2019-05-08 04:27:13 +00:00
make cephcsi
2018-07-31 09:31:12 +00:00
```
Building Docker image:
2019-02-06 06:25:52 +00:00
2018-07-31 09:31:12 +00:00
```bash
2019-05-24 11:03:33 +00:00
make image-cephcsi
2018-07-31 09:31:12 +00:00
```
## Configuration
**Available command line arguments:**
2020-02-10 08:51:05 +00:00
| Option | Default value | Description |
2020-07-10 10:44:59 +00:00
| ------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
2020-02-10 08:51:05 +00:00
| `--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket |
| `--drivername` | `cephfs.csi.ceph.com` | Name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value) |
| `--nodeid` | _empty_ | This node's ID |
2020-08-21 12:05:26 +00:00
| `--type` | _empty_ | Driver 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` |
2020-02-10 08:51:05 +00:00
| `--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 |
| `--pidlimit` | _0_ | Configure 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. |
2020-01-24 16:26:56 +00:00
| `--metricsport` | `8080` | TCP port for liveness metrics requests |
2020-02-10 08:51:05 +00:00
| `--metricspath` | `/metrics` | Path of prometheus endpoint where metrics will be available |
2020-01-24 16:26:56 +00:00
| `--enablegrpcmetrics` | `false` | [Deprecated] Enable grpc metrics collection and start prometheus server |
2020-02-10 08:51:05 +00:00
| `--polltime` | `60s` | Time interval in between each poll |
| `--timeout` | `3s` | Probe timeout in seconds |
2022-06-14 13:35:04 +00:00
| `--clustername` | _empty_ | Cluster name to set on subvolume |
2020-01-24 16:26:56 +00:00
| `--histogramoption` | `0.5,2,6` | [Deprecated] Histogram option for grpc metrics, should be comma separated value (ex:= "0.5,2,6" where start=0.5 factor=2, count=6) |
2020-02-10 08:51:05 +00:00
| `--forcecephkernelclient` | `false` | Force enabling Ceph Kernel clients for mounting on kernels < 4.17 |
2022-07-06 15:46:12 +00:00
| `--kernelmountoptions` | _empty_ | Comma separated string of mount options accepted by cephfs kernel mounter |
| `--fusemountoptions` | _empty_ | Comma separated string of mount options accepted by ceph-fuse mounter |
2020-01-24 16:26:56 +00:00
| `--domainlabels` | _empty_ | Kubernetes 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") |
2019-10-10 10:15:44 +00:00
**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.**
2018-07-31 09:31:12 +00:00
2019-02-18 04:47:31 +00:00
**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).
2018-12-19 14:26:16 +00:00
2018-07-31 09:31:12 +00:00
**Available volume parameters:**
2019-07-04 09:49:57 +00:00
| Parameter | Required | Description |
2022-12-09 16:56:35 +00:00
|-----------------------------------------------------------------------------------------------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
2019-07-04 09:49:57 +00:00
| `clusterID` | yes | String 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 |
| `fsName` | yes | CephFS filesystem name into which the volume shall be created |
2019-09-05 06:43:53 +00:00
| `mounter` | no | Mount 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". |
2019-08-21 09:28:02 +00:00
| `pool` | no | Ceph pool into which volume data shall be stored |
2020-07-10 10:44:59 +00:00
| `volumeNamePrefix` | no | Prefix to use for naming subvolumes (defaults to `csi-vol-` ). |
| `snapshotNamePrefix` | no | Prefix to use for naming snapshots (defaults to `csi-snap-` ) |
2022-04-06 15:48:27 +00:00
| `backingSnapshot` | no | Boolean value. The PVC shall be backed by the CephFS snapshot specified in its data source. `pool` parameter must not be specified. (defaults to `false` ) |
2019-08-28 09:47:12 +00:00
| `kernelMountOptions` | no | Comma separated string of mount options accepted by cephfs kernel mounter, by default no options are passed. Check man mount.ceph for options. |
| `fuseMountOptions` | no | Comma separated string of mount options accepted by ceph-fuse mounter, by default no options are passed. |
2019-07-04 09:49:57 +00:00
| `csi.storage.k8s.io/provisioner-secret-name` , `csi.storage.k8s.io/node-stage-secret-name` | for Kubernetes | Name 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-namespace` | for Kubernetes | Namespaces of the above Secret objects |
2022-12-09 16:56:35 +00:00
| `encrypted` | no | disabled by default, use `"true"` to enable fscrypt encryption on PVC and `"false"` to disable it. **Do not change for existing storageclasses** |
| `encryptionKMSID` | no | required if encryption is enabled and a kms is used to store passphrases |
2019-05-28 19:03:18 +00:00
**NOTE:** An accompanying CSI configuration file, needs to be provided to the
running pods. Refer to [Creating CSI configuration ](../examples/README.md#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:**
2018-07-31 09:31:12 +00:00
Admin credentials are required for provisioning new volumes
2019-02-06 06:25:52 +00:00
2018-07-31 09:31:12 +00:00
* `adminID` : ID of an admin client
* `adminKey` : key of the admin client
2019-05-28 19:03:18 +00:00
**Required secrets for statically provisioned volumes:**
2018-07-31 09:31:12 +00:00
User credentials with access to an existing volume
2019-02-06 06:25:52 +00:00
2018-07-31 09:31:12 +00:00
* `userID` : ID of a user client
* `userKey` : key of a user client
2019-02-07 09:58:38 +00:00
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
2020-07-23 03:47:23 +00:00
quota documentation](http://docs.ceph.com/docs/nautilus/cephfs/quota/)). A request
2019-02-07 09:58:38 +00:00
for a zero-sized volume means no quota attribute will be set.
2018-12-01 09:39:09 +00:00
2018-07-31 09:31:12 +00:00
## Deployment with Kubernetes
2019-12-19 15:35:58 +00:00
Requires Kubernetes 1.14+
2019-07-25 06:49:44 +00:00
2019-12-19 15:35:58 +00:00
Use the [cephfs templates ](../deploy/cephfs/kubernetes )
2018-07-31 09:31:12 +00:00
2019-02-07 09:58:38 +00:00
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](https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation),
the Docker daemon of the cluster nodes must allow shared mounts.
2018-07-31 09:31:12 +00:00
YAML manifests are located in `deploy/cephfs/kubernetes` .
2022-11-01 08:07:15 +00:00
**Create CSIDriver object:**
```bash
kubectl create -f csidriver.yaml
```
2018-07-31 09:31:12 +00:00
**Deploy RBACs for sidecar containers and node plugins:**
```bash
2019-02-06 06:25:52 +00:00
kubectl create -f csi-provisioner-rbac.yaml
kubectl create -f csi-nodeplugin-rbac.yaml
2018-07-31 09:31:12 +00:00
```
2019-02-07 09:58:38 +00:00
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.
2018-07-31 09:31:12 +00:00
2019-08-08 02:42:28 +00:00
**Deploy ConfigMap for CSI plugins:**
```bash
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 ](../examples/README.md#creating-csi-configuration )
for more information.
2021-08-26 05:28:48 +00:00
**Deploy Ceph configuration ConfigMap for CSI pods:**
```bash
2023-01-09 11:17:43 +00:00
kubectl create -f ../../../examples/ceph-conf.yaml
2021-08-26 05:28:48 +00:00
```
2018-07-31 09:31:12 +00:00
**Deploy CSI sidecar containers:**
```bash
2019-02-06 06:25:52 +00:00
kubectl create -f csi-cephfsplugin-provisioner.yaml
2018-07-31 09:31:12 +00:00
```
2020-10-23 01:53:34 +00:00
Deploys deployment of provision which includes external-provisioner
2019-03-27 08:28:42 +00:00
,external-attacher for CSI CephFS.
2018-07-31 09:31:12 +00:00
**Deploy CSI CephFS driver:**
```bash
2019-02-06 06:25:52 +00:00
kubectl create -f csi-cephfsplugin.yaml
2018-07-31 09:31:12 +00:00
```
2019-03-27 08:28:42 +00:00
Deploys a daemon set with two containers: CSI node-driver-registrar and
2019-02-07 09:58:38 +00:00
the CSI CephFS driver.
2018-07-31 09:31:12 +00:00
2021-06-14 05:01:33 +00:00
**NOTE:**
In case you want to use a different release version, replace canary with the
release version in the
[provisioner ](../deploy/cephfs/kubernetes/csi-cephfsplugin-provisioner.yaml )
and [nodeplugin ](../deploy/cephfs/kubernetes/csi-cephfsplugin.yaml ) YAMLs.
```yaml
# for stable functionality replace canary with latest release version
image: quay.io/cephcsi/cephcsi:canary
```
Check the release version [here. ](../README.md#ceph-csi-container-images-and-release-compatibility )
2018-07-31 09:31:12 +00:00
## Verifying the deployment in Kubernetes
2019-02-06 06:25:52 +00:00
After successfully completing the steps above, you should see output similar to this:
2018-07-31 09:31:12 +00:00
```bash
$ kubectl get all
NAME READY STATUS RESTARTS AGE
2019-06-20 19:30:40 +00:00
pod/csi-cephfsplugin-provisioner-0 4/4 Running 0 25s
pod/csi-cephfsplugin-rljcv 3/3 Running 0 24s
2018-07-31 09:31:12 +00:00
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
2019-06-20 19:30:40 +00:00
service/csi-cephfsplugin-provisioner ClusterIP 10.101.78.75 < none > 8080/TCP 26s
2018-07-31 09:31:12 +00:00
...
```
2019-05-28 19:03:18 +00:00
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 ](../examples/README.md#deploying-the-storage-class ) to
test the deployment further.
2018-07-31 09:31:12 +00:00
### Notes on volume deletion
2019-05-28 19:03:18 +00:00
Dynamically povisioned 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.
2019-09-26 09:55:12 +00:00
## 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. ](../charts/ceph-csi-cephfs/README.md )
2022-12-09 16:56:35 +00:00
## CephFS Volume Encryption
Requires fscrypt support in the Linux kernel and Ceph.
Key management is compatible with the
[fscrypt ](https://github.com/google/fscrypt ) userspace tool. See the
design doc [Ceph Filesystem fscrypt
Support](design/proposals/cephfs-fscrypt.md) 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 ](https://github.com/google/fscrypt ). In general KMS that
either store secrets to use directly (Vault), or allow access to the
plain password (Kubernets Secrets) work.