2018-07-31 09:31:12 +00:00
# CSI RBD Plugin
2019-02-07 09:58:38 +00:00
The RBD CSI plugin is able to provision new RBD images and
2019-02-18 04:47:31 +00:00
attach and mount those to workloads.
2018-07-31 09:31:12 +00:00
## Building
2019-02-07 09:58:38 +00:00
CSI RBD plugin can be compiled in a form of a binary file or in a form of a
Docker image. When compiled as a binary file, the result is stored in
2019-05-08 04:27:13 +00:00
`_output/` directory with the name `cephcsi` . When compiled as an image, it's
stored in the local Docker image store with name `rbdplugin` .
2018-07-31 09:31:12 +00:00
Building binary:
2019-02-07 09:58:38 +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-07 09:58:38 +00:00
2018-07-31 09:31:12 +00:00
```bash
2019-02-07 09:58:38 +00:00
make image-rbdplugin
2018-07-31 09:31:12 +00:00
```
## Configuration
**Available command line arguments:**
Option | Default value | Description
------ | ------------- | -----------
`--endpoint` | `unix://tmp/csi.sock` | CSI endpoint, must be a UNIX socket
2019-03-13 05:09:58 +00:00
`--drivername` | `rbd.csi.ceph.com` | name of the driver (Kubernetes: `provisioner` field in StorageClass must correspond to this value)
2018-07-31 09:31:12 +00:00
`--nodeid` | _empty_ | This node's ID
2018-10-15 14:59:41 +00:00
`--containerized` | true | Whether running in containerized mode
2018-12-19 14:26:16 +00:00
`--metadatastorage` | _empty_ | Whether should metadata be kept on node as file or in a k8s configmap (`node` or `k8s_configmap` )
2019-03-07 21:03:33 +00:00
`--configroot` | `/etc/csi-config` | Directory in which CSI specific Ceph cluster configurations are present, OR the value `k8s_objects` if present as kubernetes secrets"
2018-07-31 09:31:12 +00:00
2018-09-18 14:28:55 +00:00
**Available environmental variables:**
2019-02-18 04:47:31 +00:00
2018-09-18 14:28:55 +00:00
`HOST_ROOTFS` : rbdplugin searches `/proc` directory under the directory set by `HOST_ROOTFS` .
2019-02-07 09:58:38 +00:00
`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
2019-02-07 09:58:38 +00:00
`POD_NAMESPACE` : if you use `k8s_configmap` as metadata store,
`POD_NAMESPACE` is used to define in which namespace you want
the configmaps to be stored
2018-12-20 09:45:42 +00:00
2018-07-31 09:31:12 +00:00
**Available volume parameters:**
Parameter | Required | Description
--------- | -------- | -----------
2019-03-02 17:29:52 +00:00
`monitors` | one of `monitors` , `clusterID` or `monValueFromSecret` must be set | Comma separated list of Ceph monitors (e.g. `192.168.100.1:6789,192.168.100.2:6789,192.168.100.3:6789` )
`monValueFromSecret` | one of `monitors` , `clusterID` or and `monValueFromSecret` must be set | a string pointing the key in the credential secret, whose value is the mon. This is used for the case when the monitors' IP or hostnames are changed, the secret can be updated to pick up the new monitors.
2019-03-12 15:57:36 +00:00
`clusterID` | one of `monitors` , `clusterID` or `monValueFromSecret` must be set | 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
2018-07-31 09:31:12 +00:00
`pool` | yes | Ceph pool into which the RBD image shall be created
`imageFormat` | no | RBD image format. Defaults to `2` . See [man pages ](http://docs.ceph.com/docs/mimic/man/8/rbd/#cmdoption-rbd-image-format )
`imageFeatures` | no | RBD image features. Available for `imageFormat=2` . CSI RBD currently supports only `layering` feature. See [man pages ](http://docs.ceph.com/docs/mimic/man/8/rbd/#cmdoption-rbd-image-feature )
2019-01-23 15:58:50 +00:00
`csi.storage.k8s.io/provisioner-secret-name` , `csi.storage.k8s.io/node-publish-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-publish-secret-namespace` | for Kubernetes | namespaces of the above Secret objects
2018-09-18 14:28:55 +00:00
`mounter` | no | if set to `rbd-nbd` , use `rbd-nbd` on nodes that have `rbd-nbd` and `nbd` kernel modules to map rbd images
2018-07-31 09:31:12 +00:00
2019-03-07 21:03:33 +00:00
NOTE: If `clusterID` parameter is used, then an accompanying Ceph cluster
configuration secret or config files needs to be provided to the running pods.
2019-03-13 13:46:56 +00:00
Refer to [Cluster ID based configuration ](../examples/README.md#cluster-id-based-configuration )
2019-03-12 15:57:36 +00:00
for more information. A suggested way to populate the clusterID is to use the
output of `ceph fsid` of the Ceph cluster to be used for provisioning.
2019-03-07 21:03:33 +00:00
2019-02-07 09:58:38 +00:00
**Required secrets:**
Admin credentials are required for provisioning new RBD images `ADMIN_NAME` :
`ADMIN_PASSWORD` - note that the key of the key-value pair is the name of the
client with admin privileges, and the value is its password
2018-07-31 09:31:12 +00:00
2019-03-12 15:57:36 +00:00
If clusterID is specified, then a secret with various keys and values as
specified in `examples/rbd/template-ceph-cluster-ID-secret.yaml` needs to be
created, with the secret name matching the string value provided as the
`clusterID` .
2019-03-02 17:29:52 +00:00
2018-07-31 09:31:12 +00:00
## Deployment with Kubernetes
Requires Kubernetes 1.11
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/rbd/kubernetes` .
**Deploy RBACs for sidecar containers and node plugins:**
```bash
2019-02-07 09:58:38 +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
**Deploy CSI sidecar containers:**
```bash
2019-02-07 09:58:38 +00:00
kubectl create -f csi-rbdplugin-provisioner.yaml
2018-07-31 09:31:12 +00:00
```
2019-03-27 06:06:20 +00:00
Deploys stateful set of provision which includes external-provisioner
,external-attacher,csi-snapshotter sidecar containers and CSI RBD plugin.
2018-07-31 09:31:12 +00:00
**Deploy RBD CSI driver:**
```bash
2019-02-07 09:58:38 +00:00
kubectl create -f csi-rbdplugin.yaml
2018-07-31 09:31:12 +00:00
```
2019-03-27 06:06:20 +00:00
Deploys a daemon set with two containers: CSI node-driver-registrar and the CSI
RBD driver.
2018-07-31 09:31:12 +00:00
## Verifying the deployment in Kubernetes
2019-02-20 10:00:18 +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
pod/csi-rbdplugin-fptqr 2/2 Running 0 21s
2019-03-27 06:06:20 +00:00
pod/csi-rbdplugin-provisioner-0 4/4 Running 0 22s
2018-07-31 09:31:12 +00:00
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/csi-rbdplugin-provisioner ClusterIP 10.104.2.130 < none > 12345/TCP 23s
...
```
You can try deploying a demo pod from `examples/rbd` to test the deployment further.
2019-01-07 16:25:40 +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 `deploy/rbd/helm` .
**Deploy Helm Chart:**
```bash
2019-02-07 09:58:38 +00:00
helm install ./deploy/rbd/helm
2019-01-07 16:25:40 +00:00
```
The Helm chart deploys all of the required resources to use the CSI RBD driver.
After deploying the chart you can verify the deployment using the instructions
above for verifying the deployment with Kubernetes