Build a MAAS and LXD environment in 30 minutes with Multipass on Ubuntu

The LXD config (and it’s storage configuration) is included as part of maas.yml - see the content section at the top of the file. You’d need to alter that as well in order to give more storage to lxd (and make sure the VM has enough storage too):

- content: |
    config:
      core.https_address: '[::]:8443'
      core.trust_password: password
    networks:
    - config:
        ipv4.address: 10.10.10.1/24
        ipv6.address: none
      description: ""
      name: lxdbr0
      type: ""
      project: default
    storage_pools:
    - config:
        size: 24GB
      description: ""
      name: default
      driver: zfs
    profiles:
    - config: {}
      description: ""
      devices:
        eth0:
          name: eth0
          network: lxdbr0
          type: nic
        root:
          path: /
          pool: default
          type: disk
      name: default
    projects: []
    cluster: null
  path: /tmp/lxd.cfg
1 Like

Go back to the terminal you started earlier, which should still be logged in to the multipass shell on your MAAS VM

First time caller, long time listener here. Thought I might share: You’ve not included any step that I found, which connects the dots in order to ever have, nor connect now, to the particular shell.

Had to google it.

1 Like

Hi @anton5mith this tutorial no longer initializes LXD correctly (i.e. lxdbr0 is not created). I believe it is due to

Error: Failed to create local member network “lxdbr0” in project “default”: The DNS and DHCP service exited prematurely: exit status 2 (“dnsmasq: failed to create listening socket for 10.10.10.1: Address already in use”)

1 Like

@jjoschko I think this tutorial has not been validated for recent releases of LXD. I see a similar issue when running the tutorial.

If I disable maas, configure LXD, and then enable maas I am able to add the LXD host as expected. I get a strange error when attempting to start a VM: " Error: Ensure this value is less than or equal to 0." for both CPU count and memory allocation.

(Edit):
If you switch the lxd snap installation to use channel 5.0/stable, the tutorial works as expected. Here is the revised configuration file. After some investigation, it looks like one of the config options (core.trust_password) has been removed in the latest version of lxd. This is likely causing lxd init to fail in the cloud-init script

I was at the start of the tutorial and launched ‘foo’ and ran the command successfully. Deleting it threw an odd error:
$ multipass delete -vvvvvv --purge foo
[2024-09-18T19:05:38.757] [debug] [daemon] Deleting instance: foo
[2024-09-18T19:05:38.757] [info] [foo] Forcing shutdown
[2024-09-18T19:05:38.757] [info] [foo] Killing process
[2024-09-18T19:05:38.851] [info] [foo] process state changed to NotRunning
[2024-09-18T19:05:38.851] [error] [foo] process error occurred Crashed program: qemu-system-x86_64; error: Process crashed
[2024-09-18T19:05:38.884] [error] [foo] error: program: qemu-system-x86_64; error: Process crashed
[2024-09-18T19:05:38.885] [debug] [foo] Dropping cached SSH session
[2024-09-18T19:05:39.098] [trace] [daemon] Removing AppArmor policy:

Should I ignore the qemu crash? Or is it a sign of a compatibility problem? I’m running Ubuntu 24.04.1 (fresh install today) on a HP xw6600 workstation - Core2 Quad vintage.

Sorry for posting here. I’m not sure where this belongs.

@kmcgrego I receive a similar error on my AMD Ryzen based system. My understanding is that this is an artifact of using --purge, which forces a shutdown instead of gracefully shutting down the VM. Here is what it looks like on my machine, for a sanity check.

<alexlukens@laptop>~$ multipass launch
Launched: lithe-armadillo
<alexlukens@laptop>~$ multipass delete lithe-armadillo
<alexlukens@laptop>~$ multipass launch
Launched: limber-dobsonfly
<alexlukens@laptop>~$ multipass delete --purge limber-dobsonfly
[2024-09-18T15:56:51.361] [error] [limber-dobsonfly] process error occurred Crashed program: qemu-system-x86_64; error: Process crashed
[2024-09-18T15:56:51.365] [error] [limber-dobsonfly] error: program: qemu-system-x86_64; error: Process crashed
<alexlukens@laptop>~$

Further to the great idea to install a k8s control plane in virtual machines using MAAS, it seems that the MAAS v.3.5 snap is broken. It is impossible to create LXD VMs with MAAS (details below).

Having spent 5 days since last friday to investigate and nail down the issue on an isolated hardware setup, clean Ubuntu v 24 LTS and most recent MAAS software channel 3.5, I am stuck.

Could someone in the community please give me some pointers to get back on the yellow brickroad? That would be awesome. Thanks already.

The problem:

=====

What is broken is that it is not possible to get VMs working on a MAAS controlled VM host.

I am trying to replicate the great Way Of Work of Anton Smith to slash on-prem cost with cluster API and MAAS for bare metal k8s. (Link: https://www.youtube.com/watch?v=rvDQl_1b4VM)

In the comment section of said video there are others complaining that this does not work anymore with newer versions of MAAS & LXD software.

Some details below:

=====

Creating a LXD host in MAAS completes without problems. Attempting to create LXD VMs on any MAAS controlled LXD host fails and results in a cryptic message.

See errors below

{start snip}

example 1:
Error:
Pod unable to compose machine: (b’UNHANDLED’, ‘Unknown Error [maasplex1:pid=996:cmd=ComposeMachine:ask=3]’)

example 2:
Error:
Pod unable to compose machine: (b’UNHANDLED’, ‘Unknown Error [maasplex1:pid=1020:cmd=ComposeMachine:ask=2]’)

example 3:
Error:
Pod unable to compose machine: (b’UNHANDLED’, ‘Unknown Error [maasplex1:pid=966:cmd=ComposeMachine:ask=12]’)

{end snip}

The root cause seems to be that during install of Ubuntu 24 LTS and the MAAS v.3.5 snap the LXD v.5.21 is installed but sadly not the required bridge named “lxdbr0". Upon checkup LXD has not installed any network or bridge at all. Manually installing said lxdbr0 bridge with “lxd init” ends in an error message every time.

Any time the “lxd init” command is started, the moment the dialogue attempts to create a bridge, the dialogue breaks off with the following message:

{start snip}
Error: Failed to create local member network “lxdbr0” in project “default”: The DNS and DHCP service exited prematurely: exit status 2 (“dnsmasq: failed to create listening socket for 10.94.147.1: Address already in use”)
{end snip}

Actually, in whatever way the questions from the lxd init dialogue are answered, it always results in NOT creating that lxdbr0 bridge; Upon checking with “lxc network show lxdbr0” if lxdbr0 actually exists, it responds with the following message:

{start snip}
Error: Network not found
{end snip}

To isolate the problem I have created an isolated test network and it fails every time. Meanwhile I have completely reinstalled the maas controller 4 times on a new fresh Ubuntu server 24 LTS. The test network looks like this (see picture)

The commands used for installation are listed below:

{start snip}
based on sevral vids and articles from syncbrick and linux genie
tep 0: preparing
Dell Optiplex, KVM capable, 16GB RAM, 256Gb SSD
Fresh install of Ubuntu 24 LTS, fixed IP address.
Maas shall execute the DHCP and DNS on the subnetwork.

sudo apt update
sudo apt dist-upgrade
sudo reboot

sudo snap install --channel=3.5 maas
sudo systemctl disable --now systemd-timesyncd
sudo apt install -y postgresql
sudo reboot

sudo -i -u postgres psql -c “CREATE USER "maas" WITH ENCRYPTED PASSWORD ‘secret_password’”
sudo -i -u postgres createdb -O “maas” “maasdb”
sudo nano /etc/postgresql/16/main/pg_hba.conf
then add below lines in the existing configuration at the end of the above file
host maasdb maas 0/0 md5

sudo maas init region+rack --database-uri “postgres://maas:secret_password@localhost/maasdb”
sudo maas createadmin

step5: complete the create admin dialogue interactively, like for example:
Username : maasuser
Password : NotKnownPassword
Again : NotKnownPassword
Email : pogo.theclown@circus1.be
Import SSH Keys

sudo maas status

step 6: Once installed, log into Maas via browser using port 5240
http://192.168.6.25:5240/MAAS

change region name in welcome screen from “maas” to whatever.
region name = maas-test
change connectivity DNS servers: enter external and own
8.8.8.8 192.168.6.1
then select ‘save and continue’
next select the images to be downloaded

thereafter install SSH keys manually, so select keys->source->upload
open a terminal to the home directory and create keys
sudo ssh-keygen and enter the filename to save the key
sudo ssh-keygen -t rsa -b 2048 -C “pogoid-ssh-key”

when asked for filename enter ‘pogoed’ and enter the passphrase “NotGonnaTellYou”
check with ls for 2 files: file ‘pogoed’ is the private key and file ‘pogoid.pub’ is the public key.
show content and copy paste into MAAS browserpage and select button ímport SSH key’
cat pogoid.pub
click “finish setup”

next set DHCP on the default fabric
Select sidebar->Subnets. Then select from list with networks in the fabrics list the IPv4 network.
then select the desired VLAN HYPERLINK (!) to open the VLAN summary window.
select “configure DHCP”, select the rack controller and finish by pressing button "Configure

next step is network discoveries from sidebar menu, select update frequency
subsequently select settings from sidebar menu; settings->commissioning->machine settings
then select default ubuntu release used for commissioning
etc. etc.

{end snip}

Hope somebody can give me some essential information or point me to some stupid mistake.

Have a nice day.

Hey @kubernaut7, just read through your post. The first thing I would verify is that your installation of LXD is as you expect.

sudo snap info lxd | grep installed. As per your instructions, this should show 5.21.x.

Additionally I would try installing maas after installing and initializing lxd.
Something like this:

sudo snap remove --purge maas
sudo snap remove --purge lxd
sudo snap install lxd --channel=5.21/stable
sudo lxd init --minimal

# verify that network bridge exists here

sudo snap install maas --channel=3.5

Hope this is able to help, lxd and maas aren’t my areas of expertise. A lot of my issues above were about having the wrong version of lxd (v6.0) installed by accident. If I get a chance I will try to follow the steps you provided to see if I can replicate the issues

edit: Looks like nested lxd containers is disabled by default. Try setting lxc config items as in this article to see if it helps

(Note: for sake of completeness: I am installing MAAS without multipass; I install MAAS on a fresh Ubuntu 24 LTS computer (Dell Optiplex 3050, 16GB RAM) with real bare metal hardware (A Dell C6100 with 4 nodes)

Hi Alexdlukens,

Thanks for your reply.
I uninstalled LXD, then reinstalled the LXD snap, as per your instructions.
Upon checking the lxdbr0 bridge is now present.
That is fix number one :wink:

Then I reinstalled MAAS snap v3.5.
Next redeployed one hardware node as a LXD host.
Then tried to create a VM on top of said node.

And when reading my own comments again, I was suddenly conscious that I did not check the BIOS on the Dell C6100 itself. That was fix number 2. Once Virtualization for the Intel Xeon was switched on, it was smooth sailing from there onwards.

result?

the VM can be defined and is installed without much adoo.

Thanks a thousand, alex, you rock.

best regards,
KubeNaut7

P.S.: for the reader looking for a solution concerning MAAS snap v.3.5.

step1: install LXD before MAAS
sudo snap install lxd --channel=5.21/stable
sudo lxd init --minimal
executing “snap list | grep lxd” should give output such as:
“lxd 5.21.2-2f4ba6b 30131 5.21/stable/… canonical** -”

step2: verify that network bridge exists
lxc network show lxdbr0
that should give output such as:
afbeelding

step3: verify in BIOS of the hardware computer under management of MAAS, that the CPU has virtualization enabled.

step4: (re)install MAAS and finish config.

step5: deploy one hardware node as LXD host
select sidebar menu->machines->select the checkbox in front of one available hardware node->then select from the top bar menu the “action” and select the option “deploy” from the dropdown. subsequently a dialogue opens. select “register as a MAAS VM host” and finish the dialogue box. The MAAS controller starts deploying the hardware node as a LXD host. When finished it will show up in the machines list as deployed…

step 6: create a VM on top of the LXD host.
select sidebar menu->LXD->select the LXD host defined in step 5-> then select the button “Add VM+” and create the VM. After acceptance the MAAS controller starts deployment of the VM.

Hope this helps.

have a nice day, TTFN, KubeNaut7

Hi all,

Further to deploying a LXD host with MAAS, does anyone know why it is possible to create a LXD host when Ubuntu 22 LTS image is selected but NOT when the Ubuntu 24 LTS image is selected?

Is LXD host support deprecated with Ubuntu 24 LTS?

have a nice day,

KubeNaut7

Is LXD host support deprecated with Ubuntu 24 LTS?

No, the option in the UI will be available in the next release. IIRC if you use the CLI you should be able to do it

@r00ta could someone from the MAAS team please check this tutorial and that it actually works? it is listed on the front page for maas.io and if users can’t get it. to work out of the box, then it’s really bad for MAAS :(.