Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Commit ba4b771

Browse files
authored
Merge pull request #89 from kinvolk/kai/plain-qemu-recreate-node
bootstrap: recreate node when PXE boot is forced with plain QEMU
2 parents ac4883c + 6df3ac4 commit ba4b771

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,34 @@ To upgrade to the latest version which may have breaking changes, run `racker up
8282

8383
Both will update the `lokoctl` and `terraform` binaries, too.
8484

85+
### Lokomotive Baremetal Development Environment
86+
87+
The part of Racker which creates the Lokomotive configuration can be run stand-alone to set up libvirt QEMU instances on your laptop.
88+
This is different from the [IPMI QEMU simulator environment](racker-sim/) which is preferred as it fully utilizes Racker.
89+
However, for quick development of Racker/Lokomotive this is how to run it:
90+
91+
```
92+
cd /var/tmp/
93+
mkdir mycluster # "prepare.sh create" must run in an empty folder with just the controller_macs/worker_macs files
94+
cd mycluster
95+
echo 0c:42:a1:11:11:11 > controller_macs
96+
echo 0c:42:a1:11:11:22 > worker_macs
97+
# compile the right Lokomotive branch used in Racker (see installer/conf.yaml)
98+
sudo rm -r /opt/racker/terraform/
99+
sudo mkdir -p /opt/racker/terraform
100+
sudo cp -r /home/$USER/kinvolk/lokomotive/assets/terraform-modules/matchbox-flatcar/* /opt/racker/terraform
101+
PATH="$PATH:/home/$USER/kinvolk/lokomotive" /home/$USER/kinvolk/racker/bootstrap/prepare.sh create
102+
[…]
103+
PATH="$PATH:/home/$USER/kinvolk/lokomotive" lokoctl cluster apply # or any other things you want to do
104+
[…]
105+
# later destroy it again:
106+
PATH="$PATH:/home/$USER/kinvolk/lokomotive" /home/$USER/kinvolk/racker/bootstrap/prepare.sh destroy
107+
```
108+
109+
It will create two bridges, one for the internal PXE and one for the network with Internet access (using NAT).
110+
Matchbox and dnsmasq are started as containers (when using Podman matchbox is a user container and dnsmasq a root container).
111+
The `/opt/racker-state/` folder gets populated with the Flatcar image and the Matchbox configuration.
112+
85113
## Code of Conduct
86114

87115
Please refer to the Kinvolk [Code of Conduct](https://github.com/kinvolk/contribution/blob/master/CODE_OF_CONDUCT.md).

bootstrap/prepare.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,11 @@ function gen_cluster_vars() {
523523
name="controller"
524524
fi
525525
for mac in ${MAC_ADDRESS_LIST[*]}; do
526-
node_color="$(echo "$NODES" | grep ${mac} | cut -d , -f 4 | xargs)"
526+
if [ -n "$USE_QEMU" ]; then
527+
node_color=""
528+
else
529+
node_color="$(echo "$NODES" | grep ${mac} | cut -d , -f 4 | xargs)"
530+
fi
527531
ip_address="$(calc_ip_addr $mac)"
528532
if [ "$type" = "lokomotive" ]; then
529533
id="${CLUSTER_NAME}-${name}-${count}.${KUBERNETES_DOMAIN_NAME}"
@@ -630,7 +634,7 @@ EOF
630634
tee -a "${variable_file}" >/dev/null <<-EOF
631635
kernel_console = []
632636
install_pre_reboot_cmds = ""
633-
pxe_commands = "sudo virt-install --name \$domain --network=bridge:${INTERNAL_BRIDGE_NAME},mac=\$mac --network=bridge:${EXTERNAL_BRIDGE_NAME} --memory=${VM_MEMORY} --vcpus=1 --disk pool=default,size=${VM_DISK} --os-type=linux --os-variant=generic --noautoconsole --events on_poweroff=preserve --boot=hd,network"
637+
pxe_commands = "sudo virsh destroy \$domain || true; sudo virsh undefine \$domain || true; sudo virsh pool-refresh default || true; sudo virsh vol-delete --pool default \$domain.qcow2 || true; sudo virt-install --name \$domain --network=bridge:${INTERNAL_BRIDGE_NAME},mac=\$mac --network=bridge:${EXTERNAL_BRIDGE_NAME} --memory=${VM_MEMORY} --vcpus=1 --disk pool=default,size=${VM_DISK} --os-type=linux --os-variant=generic --noautoconsole --events on_poweroff=preserve --boot=hd,network"
634638
EOF
635639
else
636640
# The first ipmitool raw command is used to disable the 60 secs timeout that clears the boot flag

0 commit comments

Comments
 (0)