The container runtime CRI-O limits the number of PIDs to 1024 by default. When many PVCs are requested at the same time, it is possible for the provisioner to start too many threads (or go routines) and executing 'rbd' commands can start to fail. In case a go routine can not get started, the process panics. The PID limit can be changed by passing an argument to kubelet, but this will affect all pids running on a host. Changing the parameters to kubelet is also not a very elegant solution. Instead, the provisioner pod can change the configuration itself. The pod is running in privileged mode and can write to /sys/fs/cgroup where the limit is configured. With this change, the limit is configured to 'max', just as if there is no limit at all. The logs of the csi-rbdplugin in the provisioner pod will reflect the change it makes when starting the service: $ oc -n rook-ceph logs -c csi-rbdplugin csi-rbdplugin-provisioner-0 .. I0726 13:59:19.737678 1 cephcsi.go:127] Initial PID limit is set to 1024 I0726 13:59:19.737746 1 cephcsi.go:136] Reconfigured PID limit to -1 (max) .. It is possible to pass a different limit on the commandline of the cephcsi executable. The following flag has been added: --pidlimit=<int> the PID limit to configure through cgroups This accepts special values -1 (max) and 0 (default, do not reconfigure). Other integers will be the limit that gets configured in cgroups. Signed-off-by: Niels de Vos <ndevos@redhat.com>
9.4 KiB
CSI RBD Plugin
The RBD CSI plugin is able to provision new RBD images and attach and mount those to workloads.
Building
CSI 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
_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:
Option | Default value | Description |
---|---|---|
--endpoint |
unix://tmp/csi.sock |
CSI endpoint, must be a UNIX socket |
--drivername |
rbd.csi.ceph.com |
Name of the driver (Kubernetes: provisioner field in StorageClass must correspond to this value) |
--nodeid |
empty | This node's ID |
--type |
empty | Driver type `[rbd |
--containerized |
true | Whether running in containerized mode |
--instanceid |
"default" | Unique ID distinguishing this instance of Ceph CSI among other instances, when sharing Ceph clusters across CSI instances for provisioning |
--metadatastorage |
empty | Points to where legacy (1.0.0 or older plugin versions) metadata about provisioned volumes are kept, as file or in as k8s configmap (node or k8s_configmap respectively) |
--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. |
Available volume parameters:
Parameter | Required | Description |
---|---|---|
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 |
pool |
yes | Ceph pool into which the RBD image shall be created |
imageFormat |
no | RBD image format. Defaults to 2 . See man pages |
imageFeatures |
no | RBD image features. Available for imageFormat=2 . CSI RBD currently supports only layering feature. See man pages |
csi.storage.k8s.io/provisioner-secret-name , csi.storage.k8s.io/node-publish-secret-name |
yes (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 |
yes (for Kubernetes) | namespaces of the above Secret objects |
mounter |
no | if set to rbd-nbd , use rbd-nbd on nodes that have rbd-nbd and nbd kernel modules to map rbd images |
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:
User credentials, with required access to the pool being used in the storage class, is required for provisioning new RBD images.
Deployment with Kubernetes
Requires Kubernetes 1.13+
if your cluster version is 1.13.x please use rbd v1.13 templates or else use rbd v1.14+ 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/rbd/kubernetes
.
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 config map 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 RBD based provisioning for more information.
Deploy CSI sidecar containers:
kubectl create -f csi-rbdplugin-provisioner.yaml
Deploys stateful set of provision which includes external-provisioner ,external-attacher,csi-snapshotter sidecar containers and CSI RBD plugin.
Deploy RBD CSI driver:
kubectl create -f csi-rbdplugin.yaml
Deploys a daemon set with two containers: CSI node-driver-registrar and the CSI RBD driver.
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-rbdplugin-fptqr 2/2 Running 0 21s
pod/csi-rbdplugin-provisioner-0 4/4 Running 0 22s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/csi-rbdplugin-provisioner ClusterIP 10.104.2.130 <none> 12345/TCP 23s
...
Once the CSI plugin configuration is updated with details from a Ceph cluster of choice, you can try deploying a demo pod from examples/rbd using the instructions provided to test the deployment further.
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:
helm install ./deploy/rbd/helm
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