Mastering virtual machine management with MAAS
Errors or typos? Topics missing? Hard to read? Let us know!
If you have already taken the first step of setting up a VM host on MAAS, you're ready to delve into the art of managing your virtual machines (VMs). Whether it's adding, deleting, or configuring VMs, we've got you covered. Below are detailed guides for both UI and CLI methods, tailored to various MAAS versions.
Add a VM from the UI (MAAS v3.4)
Creating a VM via the UI, on MAAS version 3.4, is straightforward. Here's a step-by-step guide:
Navigate to KVM >
Choose the VM host by clicking on its name.
Click on Add VM.
If you wish, input a VM name.
Choose between Use any available core(s) or Pin VM to specific core(s). If choosing the latter, specify core identities.
Input the amount of RAM needed.
For advanced settings like Domain, Zone, Resource pool, or Architecture, click on Show advanced and make your modifications.
Optionally, you can Define interfaces.
Add disks if necessary by selecting Add disks.
Finally, click Compose machine to spawn your VM.
You'll find the newly composed VM in the 'Machines' tab after a brief period, during which it undergoes auto-commissioning. Resources are automatically deducted from the selected VM host.
Add a VM from the UI (MAAS v3.3 and below)
From the VM host's details view, locate the 'Take action' drop-down menu and select 'Compose'.
Choose your preferred storage pool from the provided drop-down list.
Note: When adding multiple disks, the last disk in the list will function as the boot disk.
Your new machine will be auto-commissioned, and its resources will be deducted from the VM host. The 'Machines' tab will update to reflect these changes.
Deleting a VM in MAAS is as straightforward as deleting any other machine:
Choose the machine from the machine list.
Select 'Delete' from the 'Take Action' drop-down menu.
Managing VMs with the MAAS CLI (all versions)
This section delves into the CLI approach for managing virtual machines in MAAS. We cover how to add a VM, set resource specifications, specify architecture, manage storage, define interfaces, locate VM host IDs, and delete a VM.
Additional background material on VM hosting is available for those interested in a deeper understanding.
Creating a basic VM is as simple as running:
maas $PROFILE vm-host compose $VM_HOST_ID
You can specify the resources for your VM using the cores
and memory
options:
maas $PROFILE vm-host compose $VM_HOST_ID cores=4 memory=8G
To define the architecture for your VM, add the architecture
option:
maas $PROFILE vm-host compose $VM_HOST_ID architecture=amd64
Disk and storage configuration can also be defined when you create a VM:
maas $PROFILE vm-host compose $VM_HOST_ID disks=1:size=20G
Network interfaces can be specified during VM creation:
maas $PROFILE vm-host compose $VM_HOST_ID interfaces=0:space=default
To find the ID for your VM host, you can use the following command:
maas $PROFILE vm-hosts read
To delete a VM, execute:
maas $PROFILE machine delete $SYSTEM_ID
Here's a quick summary of the CLI commands covered:
maas $PROFILE vm-host compose $VM_HOST_ID
maas $PROFILE vm-host compose $VM_HOST_ID cores=4 memory=8G
maas $PROFILE vm-host compose $VM_HOST_ID architecture=amd64
maas $PROFILE vm-host compose $VM_HOST_ID disks=1:size=20G
maas $PROFILE vm-host compose $VM_HOST_ID interfaces=0:space=default
maas $PROFILE vm-hosts read
maas $PROFILE machine delete $SYSTEM_ID
Additional background material on VM hosting is available for those interested in a deeper understanding.
Hopefully, this documentation provides a comprehensive guide on VM management in MAAS. Would you like to know more? Feel free to ask questions.