How to configure your Node to be able to host VMs
Hosting Virtual Machines requires some configurations steps, even
with SlapOS. If you want to serve VMs instances from your SlapOS
node(s), follow this guide.
If your node has been installed from dedicated disk image (such as USB key), there is no need of this configuration.
Network Configuration
We can now start proper network configuration of SlapOS to host Virtual
machines.
If you want to host virtual machines, you will need to configure a
bridge in order to support multiple tap interfaces used in virtual
machines like KVM. Then we can run slapformat and get ready to use the
server.
Using bridges on your computer/server can sometimes be tricky. This is
why it is not enabled by default on SlapOS. For example, it won't work
properly if using Wi-Fi.
Please also note that KVM instances won't have internet access if you
don't configure bridge, but if you only plan to only develop/test it, it
should not be a problem.
Note : the VIFIB cloud, handled by SlapOS team, uses bridge configured
automatically by the SlapOS disk image.
Bridge (Debian)
/etc/network/interfaces
iface eth0 inet manual
auto br0
iface br0 inet dhcp
bridge_ports eth0
/etc/rc.local
/opt/slapos/bin/slapformat -c /etc/opt/slapos/slapos.cfg
/opt/slapos/bin/bang /etc/opt/slapos/slapos.cfg
Note: this will not work with Wi-Fi connection.
On a Debian based distribution (Debian, Ubuntu, Mint, ...), setting up
a bridge can be achieved by changing the file /etc/network/interfaces
and restarting network. Make sure you add relevant physical interfaces
to the bridge. Make also sure that if you add a bridge to a remote
server, you still have a way to contact the server in case of failure
of the configuration (this happens very frequently).
Bridge (Generic)
/etc/rc.local
brctl addbr br0
brctl addif br0 eth0
ip l s dev br0 up
Note : this will not work with Wi-Fi connection.
On a generic GNU/Linux distribution, bridge setup can be achieved
entirely from /etc/rc.local, together with slapformat. This is not the
most beautiful way to achieve the expected result but it works.
Please also take not that any interface added to a bridge should no
longer be configured by the system. The configuration file for that
interface should just be removed.
SlapOS Configuration
# nano /etc/opt/slapos/slapos.cfg
Change under [slapformat] parameters to show:
interface_name = br0
create_tap = true
Then run slapformat again:
# slapos node format --now
Here we need to tell SlapOS installation that we should use our newly
created "br0" bridge as interface to use.
Then we ask slapformat (the tool that allocates IPs for each partition) to
create "TAP" virtual interfaces for each partition, then connect them to
the bridge.
Note: make sure you are using latest SlapOS version. "create_tap" option is
not available in old releases.
KVM configuration
# modprobe kvm
# modprobe kvm_intel
# modprobe kvm_amd
# chmod 666 /dev/kvm
Change under [slapformat] parameters to show:
interface_name = br0
use_tap = true
-
Make sure you have activated virtualization technology in the BIOS
of your computer.
-
Load the required kernel modules (Debian: # modprobe kvm kvm-intel or
modprobe kvm kvm-amd) and then change the rights of /dev/kvm to 777.