From 36f0246f329d55054fbdfde4b85cd86ea90e8941 Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Mon, 18 Oct 2021 17:14:36 +0200 Subject: [PATCH] doc/cephadm: add DiD box documentation Signed-off-by: Pere Diaz Bou --- doc/dev/cephadm/developing-cephadm.rst | 174 ++++++++++++++++++++----- 1 file changed, 141 insertions(+), 33 deletions(-) diff --git a/doc/dev/cephadm/developing-cephadm.rst b/doc/dev/cephadm/developing-cephadm.rst index 78b54ad11c0af..2b34ac41c0a75 100644 --- a/doc/dev/cephadm/developing-cephadm.rst +++ b/doc/dev/cephadm/developing-cephadm.rst @@ -99,44 +99,14 @@ Run cephadm like so:: --ssh-private-key /home//.ssh/id_rsa \ --skip-mon-network \ --skip-monitoring-stack --single-host-defaults \ - --skip-dashboard \ + --skip-dashboard \ --shared_ceph_folder /home//path/to/ceph/ - ``~/.ssh/id_rsa`` is used as the cluster key. It is assumed that this key is authorized to ssh with no passphrase to root@`hostname`. Source code changes made in the ``pybind/mgr/`` directory then -require a daemon restart to take effect. - -Note regarding network calls from CLI handlers -============================================== - -Executing any cephadm CLI commands like ``ceph orch ls`` will block the -mon command handler thread within the MGR, thus preventing any concurrent -CLI calls. Note that pressing ``^C`` will not resolve this situation, -as *only* the client will be aborted, but not execution of the command -within the orchestrator manager module itself. This means, cephadm will -be completely unresponsive until the execution of the CLI handler is -fully completed. Note that even ``ceph orch ps`` will not respond while -another handler is executing. - -This means we should do very few synchronous calls to remote hosts. -As a guideline, cephadm should do at most ``O(1)`` network calls in CLI handlers. -Everything else should be done asynchronously in other threads, like ``serve()``. - -Note regarding different variables used in the code -=================================================== - -* a ``service_type`` is something like mon, mgr, alertmanager etc defined - in ``ServiceSpec`` -* a ``service_id`` is the name of the service. Some services don't have - names. -* a ``service_name`` is ``.`` -* a ``daemon_type`` is the same as the service_type, except for ingress, - which has the haproxy and keepalived daemon types. -* a ``daemon_id`` is typically ``..``. - (Not the case for e.g. OSDs. OSDs are always called OSD.N) -* a ``daemon_name`` is ``.`` +require a daemon restart to take effect. Kcli: a virtualization management tool to make easy orchestrators development ============================================================================= @@ -154,7 +124,7 @@ main advantages: - "Close to production" lab. The resulting lab is close to "real" clusters in QE labs or even production. It makes it easy to test "real things" in an almost "real" environment. - - Safe and isolated. Does not depend of the things you have installed in + - Safe and isolated. Does not depend of the things you have installed in your machine. And the vms are isolated from your environment. - Easy to work "dev" environment. For "not compilated" software pieces, for example any mgr module. It is an environment that allow you to test your @@ -256,3 +226,141 @@ When completed, you'll see:: "Localized bundle generation complete." Then you can reload your Dashboard browser tab. + +Cephadm DiD (Docker in Docker) box development environment +========================================================== + +As kcli has a long startup time, we created an alternative which is faster using +Docker inside Docker. This approach has its downsides too as we have to +simulate the creation of osds and addition of devices with loopback devices. + +Cephadm's DiD environment is a command which requires little to setup. The setup +requires you to get the required docker images for what we call boxes and ceph. +A box is the first layer of docker containers which can be either a seed or a +host. A seed is the main box which holds cephadm and where you bootstrap the +cluster. On the other hand, you have hosts with an ssh server setup so you can +add those hosts to the cluster. The second layer, managed by cephadm, inside the +seed box, requires the ceph image. + +.. warning:: This development environment is still experimental and can have unexpected + behaviour. Please take a look at the road map and the known issues section + to see what the development progress. + +Requirements +------------ + +* `docker-compose `_ +* lvm + +Setup +----- + +In order to setup Cephadm's box run:: + + cd src/cephadm/box + sudo ln -sf "$PWD"/box.py /usr/bin/box + sudo box -v cluster setup + +.. note:: It is recommended to run box with verbose (-v). + +After getting all needed images we can run:: + + sudo box -v cluster start --osds 3 --hosts 3 + +.. note:: Cluster start will try to setup even if cluster setup was not called. +.. note:: Osds are created with loopback devices and hence, sudo is needed to + create loopback devices capable of holding osds. +.. note:: Each osd will require 5GiB of space. + +After bootstraping the cluster you can go inside the seed box in which you'll be +able to run cehpadm commands:: + + box -v cluster sh + [root@8d52a7860245] cephadm --help + ... + + +If you want to navigate to the dashboard you can find the ip address after running:: + docker ps + docker inspect | grep IPAddress + +The address will be https://$IPADDRESS:8443 + +You can also find the hostname and ip of each box container with:: + + sudo box cluster list + +and you'll see something like:: + + IP Name Hostname + 172.30.0.2 box_hosts_1 6283b7b51d91 + 172.30.0.3 box_hosts_3 3dcf7f1b25a4 + 172.30.0.4 box_seed_1 8d52a7860245 + 172.30.0.5 box_hosts_2 c3c7b3273bf1 + +To remove the cluster and clean up run:: + + box cluster down + +If you just want to clean up the last cluster created run:: + + box cluster cleanup + +To check all available commands run:: + + box --help + + +Known issues +------------ + +* If you get permission issues with cephadm because it cannot infer the keyring + and configuration, please run cephadm like this example:: + + cephadm shell --config /etc/ceph/ceph.conf --keyring /etc/ceph/ceph.kerying + +* Docker containers run with the --privileged flag enabled which has been seen + to make some computers log out. + +* Sometimes when starting a cluster the osds won't get deployed because cephadm + takes a while to update the state. If this happens wait and call:: + + box -v osd deploy --vg vg1 + +Road map +------------ + +* Run containers without --privileged +* Enable ceph-volume to mark loopback devices as a valid block device in + the inventory. +* Make DiD ready to run dashboard CI tests (including cluster expansion). + +Note regarding network calls from CLI handlers +============================================== + +Executing any cephadm CLI commands like ``ceph orch ls`` will block the +mon command handler thread within the MGR, thus preventing any concurrent +CLI calls. Note that pressing ``^C`` will not resolve this situation, +as *only* the client will be aborted, but not execution of the command +within the orchestrator manager module itself. This means, cephadm will +be completely unresponsive until the execution of the CLI handler is +fully completed. Note that even ``ceph orch ps`` will not respond while +another handler is executing. + +This means we should do very few synchronous calls to remote hosts. +As a guideline, cephadm should do at most ``O(1)`` network calls in CLI handlers. +Everything else should be done asynchronously in other threads, like ``serve()``. + +Note regarding different variables used in the code +=================================================== + +* a ``service_type`` is something like mon, mgr, alertmanager etc defined + in ``ServiceSpec`` +* a ``service_id`` is the name of the service. Some services don't have + names. +* a ``service_name`` is ``.`` +* a ``daemon_type`` is the same as the service_type, except for ingress, + which has the haproxy and keepalived daemon types. +* a ``daemon_id`` is typically ``..``. + (Not the case for e.g. OSDs. OSDs are always called OSD.N) +* a ``daemon_name`` is ``.`` -- 2.39.5