When you are using Ceph in production, it is important to have environment where you can test your upcoming upgrades, configuration changes, integration of new clusters or any other significant changes without touching real production clusters. Such environment can be simply built with the tool called Vagrant, which can very quickly build virtualized environment describe in one relatively simple config file.
We are using Vagrant on Linux with libvirt and hostmanager plugins. Libvirt is a toolkit to manage Linux KVM VMs. Vagrant can also create virtualized networks to interconnect those Vms as well as storage devices, so you can have almost identical copy of your production cluster if you need it.
Let‘s create 5 nodes Ceph cluster. All nodes First 3 nodes will be dedicated for control node daemons, all nodes will also be OSD nodes (2 x 10gb disks on each node be default), and one node will be client node. Client nodes can be used for testing access to cluster services. Mapping rbd images, moutning CephFS filesystems, accessing RGW buckets or whatecer you like. Host machine where virtualized environment can be any machine with Linux (Ubuntu 22.04 in our case) with KVM virtualization enabled.
user@hostmachine:~/$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
Install required packages:
sudo apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base
sudo apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
sudo apt-get install libguestfs-tools
sudo apt-get install build-essential
Install vagrant according the steps on official installation page: https://developer.hashicorp.com/vagrant/downloads
Then we need to install vagrant plugins:
vagrant plugin install vagrant-libvirt vagrant-hostmanager
If there is no ssh keypair in ~/.ssh, generate one. This keypair will be injected into the Vms, because cephadm which we will use for Ceph deployment needs ssh connectivity between VMs and this keypair will used for ssh authentication between nodes.
ssh-keygen
Now we should be prepared to start your virtual environment on the machine.
mkdir ceph-vagrant; cd ceph-vagrant
wget https://gist.githubusercontent.com/kmadac/171a5b84a6b64700f163c716f5028f90/raw/1cd844197c3b765571e77c58c98759db77db7a75/Vagrantfile
vagrant up
When vagrant up
ends without any error, ceph will be installed in the background for couple of more minutes. You can check deployment progress by accessing ceph shell on node0:
vagrant ssh vagrant ssh ceph1-node0
vagrant@ceph1-node0:~$ sudo cephadm shell
root@ceph1-node0:/# ceph -W cephadm –watch-debug
at the end you should get healthy ceph cluster with 3 MON daemons, and 6 OSD deamons:
root@ceph1-node0:/# ceph -s
cluster:
id: 774c4454-7d1e-11ed-91a2-279e3b86d070
health: HEALTH_OK
services:
mon: 3 daemons, quorum ceph1-node0,ceph1-node1,ceph1-node2 (age 13m)
mgr: ceph1-node0.yxrsrj(active, since 21m), standbys: ceph1-node1.oqrkhf
osd: 6 osds: 6 up (since 12m), 6 in (since 13m)
data:
pools: 1 pools, 1 pgs
objects: 0 objects, 0 B
usage: 33 MiB used, 60 GiB / 60 GiB avail
pgs: 1 active+clean
Now your cluster is up and running and you can install additional services like CephFS or RGW, you can play with adding/removing nodes, upgrading to next version. By changing CLUSTER_ID variable in Vagrantfile and copying Vagrantfile to another directory, you can deploy second cluster and try to setup replication (rbd-mirror, cephfs-mirror, RGW multizone zonfiguration) between clusters. You are only constrained by the boundaries of your imagination.
When you are done with your tests, you can simply destroy the environment with
vagrant destroy -f