Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
build_base/ | H | - | - | 93 | 67 | |
monitoring/ | H | - | - | 39 | 27 | |
spdk-app/ | H | - | - | 223 | 193 | |
traffic-generator/ | H | - | - | 117 | 92 | |
README.md | H A D | 04-Jan-2024 | 4.8 KiB | 119 | 86 | |
docker-compose.monitoring.yaml | H A D | 11-Oct-2023 | 1.2 KiB | 56 | 46 | |
docker-compose.yaml | H A D | 01-Nov-2022 | 1.9 KiB | 83 | 78 |
README.md
1# SPDK Docker suite 2 3This suite is meant to serve as an example of how SPDK can be encapsulated 4into docker container images. The example containers consist of SPDK NVMe-oF 5target sharing devices to another SPDK NVMe-oF application. Which serves 6as both initiator and target. Finally a traffic generator based on FIO 7issues I/O to the connected devices. 8Please note that some simplifications have been made to the configuration files 9for the purpose of the example, please do not use the files directly in 10the production environment. 11 12## Prerequisites 13 14docker: We recommend version 20.10 and above because it supports cgroups v2 for 15customization of host resources like CPUs, memory, and block I/O. 16 17docker-compose: We recommend using 1.29.2 version or newer. 18 19kernel: Hugepages must be allocated prior running the containers and hugetlbfs 20mount must be available under /dev/hugepages. Also, tmpfs should be mounted 21under /dev/shm. Depending on the use-case, some kernel modules should be also 22loaded into the kernel prior running the containers. 23 24proxy: If you are working behind firewall make sure dockerd is aware of the 25proxy. Please refer to: 26[docker-proxy](https://docs.docker.com/config/daemon/systemd/#httphttps-proxy) 27 28To pass `$http_proxy` to docker-compose build use: 29~~~{.sh} 30docker-compose build --build-arg PROXY=$http_proxy 31~~~ 32 33## How-To 34 35`docker-compose.yaml` shows an example deployment of the storage containers based on SPDK. 36Running `docker-compose build` creates 5 docker images: 37 38- build_base 39- storage-target 40- proxy-container 41- traffic-generator-nvme 42- traffic-generator-virtio 43 44The `build_base` image provides the core components required to containerize SPDK 45applications. The fedora:35 image from the Fedora Container Registry is used and then SPDK is installed. SPDK is installed out of `build_base/spdk.tar.gz` provided. 46See `build_base` folder for details on what's included in the final image. 47 48Running `docker-compose up` creates 3 docker containers: 49 50- storage-target: Contains SPDK NVMe-oF target exposing single subsystem to `proxy-container` based on malloc bdev. 51- proxy-container: Connecting to `storage-target` and then exposing the same devices to `traffic-generator-nvme` using NVMe-oF and to `traffic-generator-virtio` using Virtio. 52- traffic-generator-nvme: Contains FIO using SPDK plugin to connect to `proxy-container` and runs a sample workload. 53- traffic-generator-virtio: Contains FIO using SPDK plugin to connect to `proxy-container` and runs a sample workload. 54 55Each container is connected to a separate "spdk" network which is created before 56deploying the containers. See `docker-compose.yaml` for the network's detailed setup and ip assignment. 57 58All the above boils down to: 59 60~~~{.sh} 61cd docker 62tar -czf build_base/spdk.tar.gz --exclude='docker/*' -C .. . 63docker-compose build 64docker-compose up 65~~~ 66 67The `storage-target` and `proxy-container` can be started as services. 68Allowing for multiple traffic generator containers to connect. 69 70~~~{.sh} 71docker-compose up -d proxy-container 72docker-compose run traffic-generator-nvme 73docker-compose run traffic-generator-virtio 74~~~ 75 76Environment variables to containers can be passed as shown in 77[docs](https://docs.docker.com/compose/environment-variables/). 78For example extra arguments to fio can be passed as so: 79 80~~~{.sh} 81docker-compose run -e FIO_ARGS="--minimal" traffic-generator-nvme 82~~~ 83 84As each container includes SPDK installation it is possible to use rpc.py to 85examine the final setup. E.g.: 86 87~~~{.sh} 88docker-compose exec storage-target rpc.py bdev_get_bdevs 89docker-compose exec proxy-container rpc.py nvmf_get_subsystems 90~~~ 91 92## Monitoring 93 94`docker-compose.monitoring.yaml` shows an example deployment of the storage containers based on SPDK. 95 96Running `docker-compose -f docker-compose.monitoring.yaml up` creates 3 docker containers: 97 98- storage-target: Contains SPDK NVMe-oF target exposing single subsystem based on malloc bdev. 99- [telegraf](https://www.influxdata.com/time-series-platform/telegraf/) is a very minimal memory footprint agent for collecting and sending metrics and events. 100- [prometheus](https://prometheus.io/) is leading open-source monitoring solution. 101 102`telegraf` connects to `spdk` via `rpc_http_proxy.py` and uses `bdev_get_iostat` commands to fetch bdev statistics. 103 104In order to see data change, once all of the 3 containers are brought up, use `docker-compose run traffic-generator-nvme` to generate some traffic. 105 106Open Prometheus UI or query via cmdline. E.g.: 107 108~~~{.sh} 109curl --fail http://127.0.0.1:9090/api/v1/query?query=spdk_bytes_read 110curl --fail http://127.0.0.1:9090/api/v1/query?query=spdk_bytes_written 111~~~ 112 113## Caveats 114 115- If you run docker < 20.10 under distro which switched fully to cgroups2 116 (e.g. f33) make sure that /sys/fs/cgroup/systemd exists otherwise docker/build 117 will simply fail. 118- Each SPDK app inside the containers is limited to single, separate CPU. 119