Besides managing bare metal machines, MaaS (Metal as a Service) can also manage KVM guests as long as those machines are boot from network PXE. This feature allow us to efficiently manage local computing resources, while at the same time, leverage JuJu for automatically middle ware deployment. In this blog post, I will detail steps to manage KVM guest machines using MaaS.
|MaaS Managed Machine: MaaS Virtual Machine creates other Virtual machines through KVM Pod. All VMs access the internet through physical machine's NIC using NAT.|
The MaaS server will be deployed to a virtual machine running inside the physical machine. The reason for installing MaaS into a virtual machine instead of directly install to the physical machine is that we want to have the flexibility of VMs as we want to update MaaS version, or backup... The MaaS server will manage its "parent" physical machine resources through KVM pod.
All machines will access to the Internet through physical machine' NIC using NAT.
We could easily extend this diagram by adding more virtual NIC for more complex networks. We could also easily add another physical machines to MaaS, as long as the machine could be reachable by MaaS VM.
The Internet access for MaaS server is necessary because MaaS needs to fetch OS images from the remote repository.
Preinstall preparationWe will need to install kvm to the physical machine. The procedure to install KVM on Ubuntu Linux could be referred at https://help.ubuntu.com/community/KVM/Installation.
Because MaaS server will manage network resources, we need to make the modification to the "default" network to disable the DHCP for this network. MaaS needs to manage its network using DHCP in order to boot machine and automatically install OS.
To disable default, in virt-manager UI, we go to
Virt-Manager UI > Edit > Connection Details > [Virtual Networks] Tab
Remove the default network by stopping and deleting it. Re-add a new network name it "default". Modify its IP if you prefer (in my case, I use 10.23.23.0/24), remember to uncheck "Enable DHCPv4" option. Accepts other options as default.
My default network is as below
|Default Network with DHCP disabled and is NATed to the physical NIC|
With network ready, we go to install MaaS
Install MaaS Server
MaaS InstallationFor MaaS server, we will need to use normal kvm management client to create MaaS VM. We also need to download Ubuntu .iso from Ubuntu Linux homepage to install it.
The process of install MaaS is similar to installation of Ubuntu Server.
MaaS Server SettingsBecause we disabled DHCP, MaaS will not be allocated IP address, so we need to access the machine in console and setup its network.
I login into the machine console and make the following modification to /etc/netplat/50-cloud-init.yaml
Other settings like hostname ... could also be performed here. After setting up, reboot the machine for all settings applied, and to confirm that we have no problem when rebooting machines.
MaaS Installation is easily using apt
After installing MaaS, confirm that we can open MaaS web interface by access to MaaS Server port 5240. In my case it is: http://10.23.23.2:5240/MAAS/#/dashboard
2 things worth doing after MaaS installation is
- Choose OS Image so MaaS can sync it from remote repository
- Synchronization your public key from github or launchpad as you could ssh into new virtual machines.
Setup KVM PodsFrom MaaS version 2.6, MaaS server has one additional option to install KVM automatically. If you have existed machine, you should probably manually add physical machine to host to not break things.
In order to add physical machine to host, we add KVM pod to MaaS. In order for Pod to talk to physical machine, we add private ssh key to maas user to allow maas user to ssh to physical machine.
Open MaaS Web UI and add pods with virsh address as follows
Because our host ip address from virtual machine will have the ip address of 10.23.23.1, we add that IP as hypervisor endpoint. One thing to notice here is that the $USERNAME should be able to communicate with local hypervisor without the need to sudo. In the other words, the user in physical machine should belong to libvirt group.
|Add Virtual Machine as KVM Pods|
Provision Virtual MachineIf every step works without problem, you should be able to to see the Pods Summary with the number of virtual machines, its specifications.
In my case, I have a machine with 16 cores and and 32GB of RAM memory. I have 3 storage pools with different size and specifications.
Provisioning a machine is as simple as clicking [Take action] button and choose [Compose]
|Compose a new Virtual machine by choosing its spec|