Offline docs (switch to live docs)                          UI-only  CLI-only

Managing VM hosts

Once upon a time, a "vm-host" was called a "kvm"

Errors or typos? Topics missing? Hard to read? Let us know!

In order to deploy a VM host in your MAAS network, you first need to set up a bridge to connect between your VM host and MAAS itself. Once that's done, you can add and manage VM hosts -- and subsequently, create VMs to act as MAAS machines. This article explains:

To enable VM host networking features, MAAS must match the VM host IP address of a potential VM host with a known device (a machine or controller). For example, if a machine not known to MAAS is set up as a VM host, enhanced interface selection features will not be available.

It's essential to enforce usage of IP addresses to avoid domain name conflicts, should different controllers resolve the same domain name with different IP addresses. You should also avoid using 127.0.0.1 when running multiple controllers, as it would confuse MAAS.

If you need some background on VM hosting, we have a refresher available.

How to set up a VM host bridge with the web UI

To set up a VM host bridge with the Web UI:

  1. Select Machines.

  2. Select the machine you want to use as a VM host.

  3. Select Network.

  4. Select the network where you want to create the bridge.

  5. Select Create bridge.

  6. Configure the bridge on a subnet MAAS controls. You may use any IP mode for the bridge.

  7. Register your changes with Create bridge.

Then you can deploy Ubuntu.

How to set up a VM host bridge with netplan

You can also use netplan to configure a VM host bridge:

Open your netplan configuration file. This should be in /etc/netplan. It could be called 50-cloud-init.yaml, netplan.yaml, or something else. Modify the file to add a bridge, using the example below to guide you:

network:
    bridges:
        br0:
            addresses:
            - 10.0.0.101/24
            gateway4: 10.0.0.1
            interfaces:
            - enp1s0
            macaddress: 52:54:00:39:9d:f9
            mtu: 1500
            nameservers:
                addresses:
                - 10.0.0.2
                search:
                - maas
            parameters:
                forward-delay: 15
                stp: false
    ethernets:
        enp1s0:
            match:
                macaddress: 52:54:00:39:9d:f9
            mtu: 1500
            set-name: enp1s0
        enp2s0:
            match:
                macaddress: 52:54:00:df:87:ac
            mtu: 1500
            set-name: enp2s0
        enp3s0:
            match:
                macaddress: 52:54:00:a7:ac:46
            mtu: 1500
            set-name: enp3s0
    version: 2

Apply the new configuration with netplan apply.

How to set up a VM host bridge with libvirt

It is also possible to use libvirt^ to configure a virtual bridge. This method will also work for LXD VM hosts running on Ubuntu. Be aware that other methods may be required if you are configuring LXD on an OS other than Ubuntu.

By default, libvirt creates a virtual bridge, virbr0, through which VMs communicate with each other and the Internet. DHCP, supplied by libvirt, automatically assigns an IP address to each VM. However, to enable network booting in MAAS, you’ll need to provide DHCP in MAAS and either:

You can set up such a maas network like this:

cat << EOF > maas.xml
<network>
 <name>maas</name>
 <forward mode='nat'>
   <nat>
     <port start='1024' end='65535'/>
   </nat>
 </forward>
 <dns enable="no" />
 <bridge name='virbr1' stp='off' delay='0'/>
 <domain name='testnet'/>
 <ip address='172.16.99.1' netmask='255.255.255.0'>
 </ip>
</network>
EOF
virsh net-define maas.xml

Note that this network also has NAT port forwarding enabled to allow VMs to communicate with the Internet at large. Port forwarding is very useful in test environments.

How to set up SSH for use by libvirt

For MAAS to successfully communicate with libvirt on your VM host machine -- whether you're running from snap or package, or running rack controllers in LXD containers or on localhost -- this example command must succeed from every rack controller:

virsh -c qemu+ssh://$USER@$VM_HOST_IP/system list --all

Here, $USER is a user on your VM host who is a member of the libvirtd Unix group on the VM host, and $VM_HOST_IP is the IP of your VM host. Note that insufficient permissions for $USER may cause the virsh command to fail with an error such as failed to connect to the hypervisor. Check the $USER group membership to make sure $USER is a member of the libvirtd group.

How to set up SSH (libvirt only)

If you installed MAAS via snap, then create the needed SSH keys this way:

sudo mkdir -p /var/snap/maas/current/root/.ssh
cd /var/snap/maas/current/root/.ssh
sudo ssh-keygen -f id_rsa

Finally, on the VM host, you'll need to add id_rsa.pub to the authorized_keys file in /home/<vm-host-user-homedir-name>/.ssh/, where <vm-host-user-homedir-name> is the name of your VM host user.

How to add a LXD VM host with a MAAS-generated certificate

To add a LXD VM host with a MAAS-generated certificate:

  1. Select KVM > LXD.

  2. Select Add KVM.

  3. Enter a Name for the KVM host.

  4. Optionally, select a non-default Zone.

  5. Optionally, select a non-default Resource pool.

  6. Enter the LXD address as the gateway address of the bridge for that LXD instance. For example, if lxdbr0 has address 10.4.241.0, the default gateway address is 10.4.241.1.

  7. Select Generate new certificate.

  8. Select Next.

  9. Select Add trust to LXD via command line.

  10. Copy the bash command and certificate from the text box.

  11. In a terminal, paste the copied command and make sure that it runs.

  12. Select Check authentication. You'll switch screens; if all goes well, you'll see Connected with a green check-mark.

  13. Select Add new project or Select existing project. Be aware that if you select an existing project, any VMs already in that project will begin to commission.

  14. Select Next. You will drop out to a dashboard for the VM host.

You can then add virtual machines to this new VM host as desired.

How to add a LXD VM host using an existing certificate

To use your own existing certificate with a LXD VM host:

  1. Select KVM.

  2. Select Add KVM.

  3. Enter a Name for the KVM host.

  4. Optionally, select a non-default Zone.

  5. Optionally, select a non-default Resource pool.

  6. Enter the LXD address as the gateway address of the bridge for that LXD instance. For example, if lxdbr0 has address 10.4.241.0, the default gateway address is 10.4.241.1.

  7. Select Provide certificate and private key. The screen will extend.

  8. Upload a certificate or paste one in the certificate text box.

  9. Upload a private key or paste on in the private key text box.

  10. Select Next.

  11. Select Add trust to LXD via command line.

  12. Copy the bash command and certificate from the text box.

  13. In a terminal, paste the copied command and make sure that it runs.

  14. Select Check authentication. You'll switch screens; if all goes well, you'll see Connected with a green check-mark.

  15. Select Add new project or Select existing project. Be aware that if you select an existing project, any VMs already in that project will begin to commission.

  16. Select Next. You will drop out to a dashboard for the VM host.

You can then add virtual machines to this new VM host as desired.

How to delete a VM host

To delete a VM host:

  1. Select KVM.

  2. Select the VM host you wish to configure.

  3. Select KVM host settings.

  4. Select Danger zone >> Remove KVM host. You will need to confirm this choice.

There is no way to recover the VM host after confirming.

MAAS will automatically discover and store the resources your VM host contains. Any existing machines will also appear on the 'Machines' page, and MAAS will automatically attempt to commission them.

How to configure a VM host

To configure a VM host:

  1. Select KVM > LXD.

  2. Select the VM host you wish to configure.

  3. Select KVM host settings.

  4. Optionally set KVM configuration >> Zone by selecting from the drop-down.

  5. Optionally set the KVM configuration >> Resource pool by selecting from the drop-down.

  6. Optionally add or change KVM configuration >> Tags.

  7. Optionally change the KVM configuration >> CPU overcommit ratio by moving the slider.

  8. Optionally change the KVM configuration >> Memory overcommit ratio by moving the slider.

  9. If you've made changes to this point, select KVM configuration >> Save changes. MAAS will save the KVM configuration changes, but will not switch screens.

  10. If you need to change the Authentication >> Certificate, you may do so. Make sure to choose Update certificate to register your changes.

  11. If you want to remove this KVM host, choose Danger zone >> Remove KVM host. You will need to confirm this choice.

LXD clusters

MAAS takes advantage of the existing LXD clustering capability.

About LXD clusters

LXD clusters within the context of MAAS are a way of viewing and managing existing VM host clusters and composing VMs within said cluster. MAAS will not create a new cluster, but will discover an existing cluster when you provide the info for adding a single clustered host.

How to add LXD clusters

MAAS assumes you have already configured a cluster within the context of LXD. You then need to configure this cluster with a single trust MAAS will use to communicate with said cluster.

The process of adding a LXD cluster is identical to the procedure for adding a LXD VM host. The only difference is that the name you provide will be used for the cluster instead of the individual host.

MAAS will then connect to the provided host and discover the other hosts within the cluster, and rename the initially defined host with the cluster member name configured in LXD. The VM host will show up as a Cluster on the dashboard.

How to compose VMs in LXD clusters

To compose VMs in a LXD cluster, follow the procedure for adding a VM to a VM host.

How to delete LXD clusters

To delete a LXD cluster, delete any VM host within the cluster.

This will delete the cluster and all members within the cluster. Make sure that's what you want to do.