mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 10:19:35 +00:00
scripts: Add manager script for libvirt VM nodes
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
@@ -84,26 +84,35 @@ Continue to [clients](#clients) to create a client VM or attach a baremetal mach
|
||||
|
||||
## Clients
|
||||
|
||||
Once a network environment is prepared to boot client machines, create a libvirt VM configured to PXE boot or attach a baremetal machine to your Docker host.
|
||||
Create or attach PXE client machines to the network boot environment on the `docker0` bridge.
|
||||
|
||||
### libvirt VM
|
||||
|
||||
Use `virt-manager` to create a new client VM. Select Network Boot with PXE and for the network selection, choose "Specify Shared Device" with the bridge name `docker0`.
|
||||
Create 5 VMs (`node1` to `node5`) with known hardware attributes, configured to PXE-boot. The `libvirt` script can manage these 5 nodes which are used throughout the [example](data) clusters.
|
||||
|
||||
<img src='img/virt-manager.png' class="img-center" alt="Virt-Manager showing PXE network boot method"/>
|
||||
sudo ./scripts/libivrt
|
||||
USAGE: libvirt <command>
|
||||
Commands:
|
||||
create create 5 libvirt nodes
|
||||
reboot reboot the 5 libvirt nodes
|
||||
shutdown shutdown the 5 libvirt nodes
|
||||
poweroff poweroff the 5 libvirt nodes
|
||||
destroy destroy the 5 libvirt nodes
|
||||
|
||||
The VM should PXE boot using the boot and config settings based on its UUID or MAC address and your data volume. The `virt-manager` shows the UUID and the MAC address of the NIC on the shared bridge, which you can use when naming configs.
|
||||
You may use `virt-manager` to create your own VMs and view the console/state/attributes of existing VM nodes.
|
||||
|
||||
When creating your own VMs, select "Network Boot with PXE" and for network selection use "Specify Shared Device" with the bridge name `docker0`.
|
||||
|
||||
### Bare Metal
|
||||
|
||||
Connect a baremetal client machine to your libvirt Docker host machine and ensure that the client's boot firmware (probably BIOS) has been configured to prefer PXE booting.
|
||||
Connect a baremetal client machine to your host's `docker0` bridge and ensure the boot firmware (probably BIOS) is configured to prefer PXE booting.
|
||||
|
||||
Find the network interface and attach it to the virtual bridge.
|
||||
|
||||
ip link show # find new link e.g. enp0s20u2
|
||||
brctl addif docker0 enp0s20u2
|
||||
|
||||
Restart the client machine and it should PXE boot using the boot and config settings based on its UUID or MAC address and your data volume.
|
||||
Restart the client machine and it should PXE boot using settings from `bootcfg`.
|
||||
|
||||
## Next
|
||||
|
||||
|
||||
73
scripts/libvirt
Executable file
73
scripts/libvirt
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash -e
|
||||
# Manage 5 VM nodes which have a specific set of hardware attributes.
|
||||
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then echo "Please run as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
function main {
|
||||
case "$1" in
|
||||
"create") create;;
|
||||
"reboot") reboot;;
|
||||
"shutdown") shutdown;;
|
||||
"poweroff") poweroff;;
|
||||
"destroy") destroy;;
|
||||
*)
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "USAGE: ${0##*/} <command>"
|
||||
echo "Commands:"
|
||||
echo -e "\tcreate\t\tcreate 5 libvirt nodes with specific hardware attributes"
|
||||
echo -e "\treboot\t\treboot the 5 libvirt nodes"
|
||||
echo -e "\tshutdown\tshutdown the 5 libvirt nodes"
|
||||
echo -e "\tpoweroff\tpoweroff the 5 libvirt nodes"
|
||||
echo -e "\tdestroy\t\tdestroy the 5 libvirt nodes"
|
||||
}
|
||||
|
||||
function create {
|
||||
virt-install --name node1 -u 16e7d8a7-bfa9-428b-9117-363341bb330b --pxe --network=bridge:docker0 --ram=756 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
||||
virt-install --name node2 -u 264cd073-ca62-44b3-98c0-50aad5b5f819 --pxe --network=bridge:docker0 --ram=756 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
||||
virt-install --name node3 -u 39d2e747-2648-4d68-ae92-bbc70b245055 --pxe --network=bridge:docker0 --ram=756 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
||||
virt-install --name node4 -u 4ed46e8e-db69-471e-b874-0990dd65649d --pxe --network=bridge:docker0 --ram=756 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
||||
virt-install --name node5 -u 53683e94-3273-4a49-9a82-d769b88e3ccf --pxe --network=bridge:docker0 --ram=756 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
||||
}
|
||||
|
||||
function reboot {
|
||||
virsh reboot node1
|
||||
virsh reboot node2
|
||||
virsh reboot node3
|
||||
virsh reboot node4
|
||||
virsh reboot node5
|
||||
}
|
||||
|
||||
function shutdown {
|
||||
virsh shutdown node1
|
||||
virsh shutdown node2
|
||||
virsh shutdown node3
|
||||
virsh shutdown node4
|
||||
virsh shutdown node5
|
||||
}
|
||||
|
||||
function poweroff {
|
||||
virsh destroy node1
|
||||
virsh destroy node2
|
||||
virsh destroy node3
|
||||
virsh destroy node4
|
||||
virsh destroy node5
|
||||
}
|
||||
|
||||
function destroy {
|
||||
virsh undefine node1
|
||||
virsh undefine node2
|
||||
virsh undefine node3
|
||||
virsh undefine node4
|
||||
virsh undefine node5
|
||||
}
|
||||
|
||||
main $@
|
||||
Reference in New Issue
Block a user