LXD containers
LXD is a system container manager that has native support for Ceph. The images of running containers can reside in a remote Ceph cluster in the form of RADOS Block Devices, or RBD.
Note: LXD is installed by default on all supported Ubuntu releases. The snap install is recommended and is the delivery method starting with Ubuntu 20.04 LTS (Focal).
LXD+RBD client usage
This section will provide optional instructions for integrating LXD with Ceph using RBD by setting up a simple client environment. Deploy the client using the steps provided in theClient setup appendix.
Note: These instructions will use the string ‘lxd-rbd’ for a Ceph pool name, a Ceph user name, and a LXD pool name. This is merely out of convenience; each entity can be named differently.
Important: LXD hosts cannot share the same Ceph pool. Develop a naming convention for pool names if using multiple hosts.
Create a Ceph pool (‘lxd-rbd’), an RBD user (‘lxd-rbd’), collect the user’s keyring file, and transfer it to the client:
juju run --wait ceph-mon/0 create-pool name=lxd-rbd app-name=rbdjuju exec --unit ceph-mon/0 -- \ sudo ceph auth get-or-create client.lxd-rbd \ mon 'profile rbd' osd 'profile rbd pool=lxd-rbd' | \ tee ceph.client.lxd-rbd.keyringjuju scp ceph.client.lxd-rbd.keyring ceph-client/0:From the LXD client,
Configure the client using the keyring file and set up the correct permissions:
sudo mv ~ubuntu/ceph.client.lxd-rbd.keyring /etc/cephsudo chmod 600 /etc/ceph/ceph.client.lxd-rbd.keyringsudo chown ubuntu: /etc/ceph/ceph.client.lxd-rbd.keyringEnsure the current user is a member of the ‘lxd’ group and then initialise LXD (here the user is named ‘ubuntu’):
sudo adduser ubuntu lxdnewgrp lxdlxd init --autoNow create a LXD storage pool (‘lxd-rbd’) of type ‘ceph’ that is linked to the previously created ‘lxd-rbd’ Ceph user:
lxc storage create lxd-rbd ceph source=lxd-rbd ceph.user.name=lxd-rbdIf the last command throws an error such as “error connecting to the cluster” it may be necessary to use the Ceph client on the host rather than the Ceph client bundled into the LXD snap. To configure LXD to use the host’s Ceph client, run the following:
sudo snap set lxd ceph.external=truesudo systemctl reload snap.lxd.daemonConfigure the LXD default profile to use the new LXD storage pool:
lxc profile device set default root pool lxd-rbdLXD images will still be stored locally (under/var/snap/lxd/common/lxd/images). To have Ceph also store images:
lxc storage volume create lxd-rbd images size=10GiBlxc config set storage.images_volume lxd-rbd/imagesNote: Support for Ceph-backed LXD images starts withlxd 4.0.4.
Launch a test container named ‘test-instance’:
lxc launch ubuntu:22.04 test-instanceFrom the Juju client,
The location of the running container can be verified:
juju ssh ceph-mon/0 sudo rbd ls -l --pool lxd-rbdThe space used by the pool in question can be viewed in this way:
juju ssh ceph-mon/0 sudo rados df --pool lxd-rbdThis page was last modified 1 year, 7 months ago.Help improve this document in the forum.