2019-08-20 15:24:17 +02:00
---
2022-11-09 15:44:33 -07:00
title : CephClient CRD
2019-08-20 15:24:17 +02:00
---
Rook allows creation and updating clients through the custom resource definitions (CRDs).
For more information about user management and capabilities see the [Ceph docs ](https://docs.ceph.com/docs/master/rados/operations/user-management/ ).
2022-08-17 10:43:21 +09:00
## Use Case: Connecting to Ceph
2019-08-20 15:24:17 +02:00
2022-06-21 19:59:31 -04:00
Use Client CRD in case you want to integrate Rook with applications that are using LibRBD directly.
2019-08-20 15:24:17 +02:00
For example for OpenStack deployment with Ceph backend use Client CRD to create OpenStack services users.
2020-02-26 17:30:08 -07:00
The Client CRD is not needed for Flex or CSI driver users. The drivers create the needed users automatically.
2019-08-20 15:24:17 +02:00
2022-08-17 10:43:21 +09:00
### Prerequisites
This guide assumes you have created a Rook cluster as explained in the main [Quickstart guide ](../Getting-Started/quickstart.md ).
### 1. Creating Ceph User
2019-08-20 15:24:17 +02:00
To get you started, here is a simple example of a CRD to configure a Ceph client with capabilities.
```yaml
---
apiVersion : ceph.rook.io/v1
kind : CephClient
metadata :
2022-08-17 10:43:21 +09:00
name : example
2019-08-20 15:24:17 +02:00
namespace : rook-ceph
spec :
caps :
2022-08-17 10:43:21 +09:00
mon : 'profile rbd, allow r'
2019-08-20 15:24:17 +02:00
osd : 'profile rbd pool=volumes, profile rbd pool=vms, profile rbd-read-only pool=images'
```
2022-08-17 10:43:21 +09:00
To use `CephClient` to connect to a Ceph cluster:
2019-08-20 15:24:17 +02:00
2022-08-17 10:43:21 +09:00
### 2. Find the generated secret for the `CephClient`
Once your `CephClient` has been processed by Rook, it will be updated to include your secret:
```console
kubectl -n rook-ceph get cephclient example -o jsonpath='{.status.info.secretName}'
```
### 3. Extract Ceph cluster credentials from the generated secret
Extract Ceph cluster credentials from the generated secret (note that the subkey will be your original client name):
```console
kubectl --namespace rook-ceph get secret rook-ceph-client-example -o jsonpath="{.data.example}" | base64 -d
```
2024-04-22 11:54:27 -06:00
The base64 encoded value that is returned **is** the password for your ceph client.
2022-08-17 10:43:21 +09:00
### 4. Retrieve the mon endpoints
To send writes to the cluster, you must retrieve the mons in use:
```console
kubectl --namespace rook-ceph get configmap rook-ceph-mon-endpoints -o jsonpath='{.data.data}' | sed 's/.=//g'`
```
2024-04-22 11:54:27 -06:00
This command should produce a line that looks somewhat like this:
2022-08-17 10:43:21 +09:00
2024-04-22 11:54:27 -06:00
```console
2022-08-17 10:43:21 +09:00
10.107.72.122:6789,10.103.244.218:6789,10.99.33.227:6789
```
### 5. (optional) Generate Ceph configuration files
If you choose to generate files for Ceph to use you will need to generate the following files:
- General configuration file (ex. `ceph.conf` )
- Keyring file (ex. `ceph.keyring` )
Examples of the files follow:
`ceph.conf`
2024-04-22 11:54:27 -06:00
2022-08-17 10:43:21 +09:00
```ini
[global]
mon_host = 10.107.72.122:6789,10.103.244.218:6789,10.99.33.227:6789
log file = /tmp/ceph-$pid.log
```
`ceph.keyring`
2024-04-22 11:54:27 -06:00
2022-08-17 10:43:21 +09:00
```ini
[client.example]
key = < key, decoded from k8s secret>
# The caps below are for a rbd workload -- you may need to edit/modify these capabilities for other workloads
# see https://docs.ceph.com/en/latest/cephfs/capabilities
caps mon = 'allow r'
caps osd = 'profile rbd pool=<your pool>, profile rb pool=<another pool>'
```
### 6. Connect to the Ceph cluster with your given client ID
With the files we've created, you should be able to query the cluster by setting Ceph ENV variables and running `ceph status` :
2023-01-17 15:01:33 +01:00
```console
2022-08-17 10:43:21 +09:00
export CEPH_CONF=/libsqliteceph/ceph.conf;
export CEPH_KEYRING=/libsqliteceph/ceph.keyring;
export CEPH_ARGS=--id example;
ceph status
```
With this config, the ceph tools (`ceph` CLI, in-program access, etc) can connect to and utilize the Ceph cluster.
## Use Case: SQLite
2023-07-26 08:22:08 -04:00
The Ceph project contains a [SQLite VFS][sqlite-vfs] that interacts with RADOS directly, called [`libcephsqlite` ][libcephsqlite].
2022-08-17 10:43:21 +09:00
First, on your workload ensure that you have the appropriate packages installed that make `libcephsqlite.so` available:
- [`ceph` on Alpine ](https://pkgs.alpinelinux.org/package/edge/community/x86_64/ceph )
- [`libsqlite3-mod-ceph` on Ubuntu ](https://pkgs.alpinelinux.org/package/edge/community/x86_64/ceph )
- [`libcephsqlite` on Fedora ](https://pkgs.org/search/?q=libcephsqlite )
- [`ceph` on CentOS ](https://cbs.centos.org/koji/packageinfo?packageID=534 )
Without the appropriate package (or a from-scratch build of SQLite), you will be unable to load `libcephsqlite.so` .
After creating a `CephClient` similar to [`deploy/examples/sqlitevfs-client.yaml` ](https://github.com/rook/rook/blob/master/deploy/examples/sqlitevfs-client.yaml ) and retrieving it's credentials, you may set the following ENV variables:
```console
export CEPH_CONF=/libsqliteceph/ceph.conf;
export CEPH_KEYRING=/libsqliteceph/ceph.keyring;
export CEPH_ARGS=--id sqlitevfs
```
Then start your SQLite database:
```console
sqlite> .load libcephsqlite.so
sqlite> .open file:///poolname:/test.db?vfs=ceph
sqlite>
```
If those lines complete without error, you have successfully set up SQLite to access Ceph.
2023-07-26 08:22:08 -04:00
See [the libcephsqlite documentation][libcephsqlite] for more information on the VFS and database URL format.
2022-08-17 10:43:21 +09:00
[libcephsqlite]: https://docs.ceph.com/en/latest/rados/api/libcephsqlite/
[sqlite-vfs]: https://www.sqlite.org/vfs.html