This project provides block storage on top of Ceph for platforms (e.g.: VMWare) without native Ceph support (RBD), replacing existing approaches (iSCSI) with a newer and more versatile standard (NVMe-oF).
Essentially, it allows to export existing RBD images as NVMe-oF namespaces. The creation and management of RBD images is not within the scope of this component.
-
Linux-based system with at least 16 GB of available RAM. Fedora 37 is recommended.
-
SELinux in permissive mode:
sed -i s/^SELINUX=.*$/SELINUX=permissive/ /etc/selinux/config setenforce 0
moby-engine
(docker-engine
) (v20.10) anddocker-compose
(v2.11.0+). These versions are just indicativemake
(only needed to launchdocker-compose
commands).
To install these dependencies in Fedora:
sudo dnf install -y make moby-engine docker-compose-plugin
Some post-installation steps are required to use docker
with regular users:
sudo groupadd docker
sudo usermod -aG docker $USER
To launch a containerized environment with a Ceph cluster and a NVMe-oF gateway (this is not the prescribed deployment for production purposes, but for testing and development tasks alone):
-
Get this repo:
git clone https://github.com/ceph/ceph-nvmeof.git cd ceph-nvmeof git submodule update --init --recursive
-
Configure the environment (basically to allocate huge-pages, which requires entering the user password):
make setup
-
Download the container images:
make pull
-
Deploy the containers locally:
make up
-
Check that the deployment is up and running:
$ make ps Name Command State Ports ----------------------------------------------------------------------------------------------------------------------- ceph sh -c ./vstart.sh --new $V ... Up (healthy) 5000/tcp, 6789/tcp, 6800/tcp, 6801/tcp, 6802/tcp, 6803/tcp, 6804/tcp, 6805/tcp, 80/tcp nvmeof_nvmeof_1 python3 -m control -c ceph ... Up 0.0.0.0:4420->4420/tcp,:::4420->4420/tcp, 0.0.0.0:5500->5500/tcp,:::5500->5500/tcp, 0.0.0.0:8009->8009/tcp,:::8009->8009/tcp
-
The environment is ready to provide block storage on Ceph via NVMe-oF.
The following command executes all the steps required to set up the NVMe-oF environment:
$ make demo
docker compose exec ceph bash -c "rbd -p rbd info demo_image || rbd -p rbd create demo_image --size 10M"
rbd: error opening image demo_image: (2) No such file or directory
docker compose run --rm nvmeof-cli --server-address 192.168.13.3 --server-port 5500 subsystem add --subsystem "nqn.2016-06.io.spdk:cnode1"
Adding subsystem nqn.2016-06.io.spdk:cnode1: Successful
docker compose run --rm nvmeof-cli --server-address 192.168.13.3 --server-port 5500 namespace add --subsystem "nqn.2016-06.io.spdk:cnode1" --rbd-pool rbd --rbd-image demo_image
Adding namespace 1 to nqn.2016-06.io.spdk:cnode1: Successful
docker compose run --rm nvmeof-cli --server-address 192.168.13.3 --server-port 5500 listener add --subsystem "nqn.2016-06.io.spdk:cnode1" --host-name fbca1a3d3ed8 --traddr 192.168.13.3 --trsvcid 4420
Adding listener 192.168.13.3:4420 to nqn.2016-06.io.spdk:cnode1: Successful
docker compose run --rm nvmeof-cli --server-address 2001:db8::3 --server-port 5500 listener add --subsystem "nqn.2016-06.io.spdk:cnode1" --host-name fbca1a3d3ed8 --traddr 2001:db8::3 --trsvcid 4420 --adrfam IPV6
Adding listener [2001:db8::3]:4420 to nqn.2016-06.io.spdk:cnode1: Successful
docker compose run --rm nvmeof-cli --server-address 192.168.13.3 --server-port 5500 host add --subsystem "nqn.2016-06.io.spdk:cnode1" --host-nqn "*"
Allowing any host for nqn.2016-06.io.spdk:cnode1: Successful
The same configuration can also be manually run:
-
First of all, let's create the
cephnvmf
shortcut to interact with the NVMe-oF gateway:eval $(make alias)
-
In order to start working with the NVMe-oF gateway, we need to create an RBD image first (
demo_image
in therbd
pool):make rbd
-
Create a subsystem:
cephnvmf subsystem add --subsystem nqn.2016-06.io.spdk:cnode1
-
Add a namespace:
cephnvmf namespace add --subsystem nqn.2016-06.io.spdk:cnode1 --rbd-pool rbd --rbd-image demo_image
-
Create a listener so that NVMe initiators can connect to:
cephnvmf listener add ---subsystem nqn.2016-06.io.spdk:cnode1 --host-name host_name -a gateway_addr -s 4420
-
Define which hosts can connect:
cephnvmf host add --subsystem nqn.2016-06.io.spdk:cnode1 --host-nqn "*"
These can also be run by setting environment variables CEPH_NVMEOF_SERVER_ADDRESS
and CEPH_NVMEOF_SERVER_PORT
before running nvmeof-cli commands, example:
cat <<EOF > /etc/ceph/nvmeof-cli.env
CEPH_NVMEOF_SERVER_ADDRESS=x.x.x.x
CEPH_NVMEOF_SERVER_PORT=5500
EOF
// using containers
docker compose run --env-file /etc/ceph/nvmeof-cli.env -it <container_image> subsystem add --subsystem nqn.2016-06.io.spdk:cnode1
// using pypi package
source /etc/ceph/nvmeof-cli.env
ceph-nvmeof subsystem add --subsystem nqn.2016-06.io.spdk:cnode1
Once the NVMe-oF target is
-
Install requisite packages:
sudo dnf install nvme-cli sudo modprobe nvme-fabrics
-
Ensure that the listener is reachable from the NVMe-oF initiator:
$ sudo nvme discover -t tcp -a 192.168.13.3 -s 4420 Discovery Log Number of Records 1, Generation counter 2 =====Discovery Log Entry 0====== trtype: tcp adrfam: ipv4 subtype: nvme subsystem treq: not required portid: 0 trsvcid: 4420 subnqn: nqn.2016-06.io.spdk:cnode1 traddr: 192.168.13.3 eflags: not specified sectype: none
-
Connect to desired subsystem:
sudo nvme connect -t tcp --traddr 192.168.13.3 -s 4420 -n nqn.2016-06.io.spdk:cnode1
-
List the available NVMe targets:
$ sudo nvme list Node Generic SN Model Namespace Usage Format FW Rev --------------------- --------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- -------- /dev/nvme1n1 /dev/ng1n1 Ceph00000000000001 Ceph bdev Controller 1 10,49 MB / 10,49 MB 4 KiB + 0 B 23.01 ...
-
Create a filesystem on the desired target:
$ sudo mkfs /dev/nvme1n1 mke2fs 1.46.5 (30-Dec-2021) Discarding device blocks: done Creating filesystem with 2560 4k blocks and 2560 inodes Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done
-
Mount and use the storage volume
$ mkdir /mnt/nvmeof $ sudo mount /dev/nvme1n1 /mnt/nvmeof $ ls /mnt/nvmeof lost+found $ sudo bash -c "echo Hello NVMe-oF > /mnt/nvmeof/hello.txt" $ cat /mnt/nvmeof/hello.txt Hello NVMe-oF
The discovery service can provide all the targets that the current user can access, and these target information is sourced from ceph omap. These targets may be running or just a record.
-
Start Discovery Service
$ python3 -m control.discovery
-
To start discovery service container in docker-compose environment
$ docker compose up --detach discovery
-
Discover targets from discovery service. The default port is 8009.
$ nvme discover -t tcp -a 192.168.13.3 -s 8009
This service comes with a pre-defined configuration that matches the most common use cases. For advanced configuration, please update the settings at the .env
file. That file is automatically read by docker-compose
. However, it's a perfectly valid bash source, so that it can also be used as:
source .env
echo $NVMEOF_VERSION...
For testing purposes, self signed certificates and keys can be generated locally using OpenSSL.
For the server, generate credentials for the server named 'my.server' and save them in files called server.key and server.crt. Additionally, specify subject alternative names using the gateway group nodes' IPs in the openssl command.
$ openssl req -x509 -newkey rsa:4096 -nodes -keyout server.key -out server.crt -days 3650 -subj '/CN=my.server' -addext "subjectAltName=IP:192.168.13.3,IP:192.168.13.4,IP:192.168.13.5,IP:192.168.13.6"
For client:
$ openssl req -x509 -newkey rsa:4096 -nodes -keyout client.key -out client.crt -days 3650 -subj '/CN=client1'
Indicate the location of the keys and certificates in the config file:
[mtls]
server_key = ./server.key
client_key = ./client.key
server_cert = ./server.crt
client_cert = ./client.crt
DPDK requires hugepages to be set up:
sh -c 'echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages'
This is automatically done in the make setup
step. The amount of hugepages can be configured with make setup HUGEPAGES=512
.
The development environment relies on containers (specifically docker-compose
) for building and running the components. This has the benefit that, besides docker
and docker-compose
, no more dependencies need to be installed in the host environment.
Once the GitHub repo has been cloned, remember to initialize its git submodules (spdk
, which in turn depends on other submodules):
git submodule update --init --recursive
For building, SELinux might cause issues, so it's better to set it to permissive mode:
# Change it for the running session
sudo setenforce 0
# Persist the change across boots
sudo sed -i -E 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
To avoid having to deal with docker-compose
commands, this provides a Makefile
that wraps those as regular make
targets:
To build the container images from the local sources:
make build
NOTE:
For Arm64 build, the default SPDK building SoC is generic
. To build SPDK for other SoC you need to override the default values of SPDK_TARGET_ARCH
and SPDK_MAKEFLAGS
. To know which values to set for all the supported Arm64 SoCs see the socs and implementer_xxx parts.
E.g. for kunpeng920 SoC:
make build SPDK_TARGET_ARCH="armv8.2-a+crypto" \
SPDK_MAKEFLAGS="DPDKBUILD_FLAGS=-Dplatform=kunpeng920"
The resulting images should be like these:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/ceph/nvmeof-cli 0.0.1 8277cd0cce2d 7 minutes ago 995MB
quay.io/ceph/nvmeof 0.0.1 34d7230dcce8 7 minutes ago 439MB
quay.io/ceph/vstart-cluster 17.2.6 cb2560975055 8 minutes ago 1.27GB
quay.io/ceph/spdk 23.01 929e22e22ffd 8 minutes ago 342MB
spdk
is an intermediate image that contains an RPM-based installation of spdk withrbd
support enabled.nvmeof
is built from thespdk
container by installing the Python package.nvmeof-cli
provides a containerized environment to run CLI commands that manage thenvmeof
service via gRPC.ceph
is a sandboxed (vstart-based) Ceph cluster for testing purposes.
For building a specific service:
make build SVC=nvmeof
To generate independent RPM and Python wheel packages:
make export-rpms export-python
RPMs exported to:
/tmp/rpm/x86_64/spdk-libs-23.01-0.x86_64.rpm
/tmp/rpm/x86_64/spdk-devel-23.01-0.x86_64.rpm
/tmp/rpm/x86_64/spdk-23.01-0.x86_64.rpm
Python wheel exported to:
/tmp/ceph_nvmeof-0.0.1-py3-none-any.whl
To install nvmeof-cli as a CLI tool from the above Python wheel package, (or alternatively only build the cli package):
make export-python
pip install /tmp/ceph_nvmeof-0.0.1-py3-none-any.whl
ceph-nvmeof // use nvmeof-cli tool!
This can also be installed from https://pypi.org/project/ceph-nvmeof/, by running pip3 install ceph-nvmeof
.
To avoid having to re-build container on every code change, developer friendly containers are provided:
docker compose up nvmeof-devel
Devel containers provide the same base layer as the production containers but with the source code mounted at run-time.
Python dependencies are specified in the file pyproject.toml
(PEP-621), specifically under the dependencies
list.
After modifying it, the dependency lockfile (pdm.lock
) needs to be updated accordingly (otherwise container image builds will fail):
make update-lockfile
git add pdm.lock
To obtain a detailed list of make
targets, run make help
:
Makefile to build and deploy the Ceph NVMe-oF Gateway
Usage:
make [target] [target] ... OPTION=value ...
Targets:
Basic targets:
clean Clean-up environment
export-python Build Ceph NVMe-oF Gateway Python package and copy it to /tmp
export-rpms Build SPDK RPMs and copy them to $(EXPORT_DIR)/rpm
setup Configure huge-pages (requires sudo/root password)
up Services
update-lockfile Update dependencies in lockfile (pdm.lock)
Options:
EXPORT_DIR Directory to export packages (RPM and Python wheel) (Default: /tmp)
up: SVC Services (Default: nvmeof)
Deployment commands (docker-compose):
build Build SVC images
down Shut down deployment
events Receive real-time events from containers
exec Run command inside an existing container
images List images
logs View SVC logs
pause Pause running deployment
port Print public port for a port binding
ps Display status of SVC containers
pull Download SVC images
push Push nvmeof and nvmeof-cli containers images to quay.io registries
restart Restart SVC
run Run command CMD inside SVC containers
shell Exec shell inside running SVC containers
stop Stop SVC
top Display running processes in SVC containers
unpause Resume paused deployment
up Launch services
Options:
CMD Command to run with run/exec targets (Default: )
DOCKER_COMPOSE Docker-compose command (Default: docker-compose)
OPTS Docker-compose subcommand options (Default: )
SCALE Number of instances (Default: 1)
SVC Docker-compose services (Default: )
Demo:
demo Expose RBD_IMAGE_NAME as NVMe-oF target
Miscellaneous:
alias Print bash alias command for the nvmeof-cli. Usage: "eval $(make alias)"
Targets may accept options: make run SVC=nvme OPTS=--entrypoint=bash
.
Each gateway daemon implements a prometheus exporter endpoint, which can expose performance and relevant metadata over port 10008/tcp. The endpoint is enabled by default, but if you don't see port 10008 listening, check the ceph-nvmeof.conf
file.
enable_prometheus_exporter = True
The image below shows a sample Grafana dashboard that provides a good starting point for monitoring the performance and configuration of an NVMe-oF gateway group.
The JSON for the dashboard can be found here, and can simply be imported into your Grafana instance. Note: Although Grafana v11 was used to develop the dashboard, it should work in v10.x as well.
See CONTRIBUTING.md
.
See LICENSE
.