You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
qemu-script: Use a second bridge for an internal network
In the final setup we can use an internal L2 network and don't need to
rely on ipvlan. This makes the QEMU setup resemble the final setup but
still keeps the PXE/DHCP server on the host system, not in a VM.
The required lokoctl binary comes from
kinvolk/lokomotive#1317
echo"Usage: USE_QEMU=1 $0 create|destroy"# TODO: add something like create-image to embed an Ignition config into a Flatcar image for the mgmt node?
13
+
echo"TODO: Make sure you disable any firewall, e.g., run sudo systemctl disable --now firewalld"
13
14
exit 1
14
15
fi
15
16
# TODO: setup trap?
16
17
18
+
SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")"
19
+
cd"$SCRIPTFOLDER"
20
+
17
21
if [[ "${EUID}"-eq 0 ]];then
18
22
echo"Please do not run as root, sudo will be used where necessary"
19
23
exit 1
20
24
fi
21
25
26
+
27
+
ls controller_macs worker_macs > /dev/null || { echo"Add at least one MAC address for each file controller_macs and worker_macs";exit 1 ; }
28
+
22
29
CONTROLLER_AMOUNT=1
23
30
if [ -n"$USE_QEMU" ];then
24
31
VM_MEMORY=2500
25
32
VM_DISK=10
26
-
BRIDGE_NAME="pxe0"
27
-
BRIDGE_ADDRESS="172.16.0.1"# TODO: use something smaller, for testing this is overlapping with the private IP address range until the "kernel_args" variable is exposed in Lokomotive to set up the private IP addr
28
-
BRIDGE_SIZE="12"
29
-
BRIDGE_BROADCAST="172.31.255.255"
30
-
DHCP_RANGE_LOW="172.16.0.2"
31
-
DHCP_RANGE_HIGH="172.31.255.254"
32
-
DHCP_NETMASK="255.240.0.0"
33
-
DHCP_ROUTER_OPTION="${BRIDGE_ADDRESS}"
33
+
# Assign a wide subnet so that it overlaps with the actual subnet used internally, allowing to reach it from the host (later the range should be the same but split between static and dynamic to avoid conflicts)
34
+
INTERNAL_BRIDGE_NAME="pxe0"
35
+
INTERNAL_BRIDGE_ADDRESS="172.16.0.1"
36
+
INTERNAL_BRIDGE_SIZE="12"
37
+
INTERNAL_BRIDGE_BROADCAST="172.31.255.255"
38
+
INTERNAL_DHCP_RANGE_LOW="172.16.0.2"
39
+
INTERNAL_DHCP_RANGE_HIGH="172.31.255.254"
40
+
INTERNAL_DHCP_NETMASK="255.240.0.0"
41
+
# Set up Internet connectivity for the non-PXE interface of each VM
# TODO: generate these two files ("ordered", e.g., sorting alphabetically?), ARP ping or ssh into ToR switch (and exclude mgmt node itself), also get BMC MAC addrs
sudo ip link delete "${EXTERNAL_BRIDGE_NAME}"type bridge ||true
93
112
fi
94
113
}
95
114
96
115
functioncreate_network() {
97
116
destroy_network
98
117
if [ -n"$USE_QEMU" ];then
99
-
echo"Creating bridge ${BRIDGE_NAME}"
118
+
echo"Creating bridge ${EXTERNAL_BRIDGE_NAME}"
119
+
120
+
sudo ip link add name "${EXTERNAL_BRIDGE_NAME}"type bridge
121
+
sudo ip link set"${EXTERNAL_BRIDGE_NAME}" up
122
+
sudo ip addr add dev "${EXTERNAL_BRIDGE_NAME}""${EXTERNAL_BRIDGE_ADDRESS}/${EXTERNAL_BRIDGE_SIZE}" broadcast "${EXTERNAL_BRIDGE_BROADCAST}"
123
+
124
+
echo"Creating bridge ${INTERNAL_BRIDGE_NAME}"
100
125
101
-
sudo ip link add name "${BRIDGE_NAME}" address aa:bb:cc:dd:ee:ff type bridge
102
-
sudo ip link set"${BRIDGE_NAME}" up
126
+
sudo ip link add name "${INTERNAL_BRIDGE_NAME}" address aa:bb:cc:dd:ee:ff type bridge
127
+
sudo ip link set"${INTERNAL_BRIDGE_NAME}" up
103
128
# Use a stable MAC address because it's the same that the matchbox interface gets, and we want to calculate a subnet from it # TODO: later create a VM with that MAC
104
-
sudo ip addr add dev "${BRIDGE_NAME}""${BRIDGE_ADDRESS}/${BRIDGE_SIZE}" broadcast "${BRIDGE_BROADCAST}"
129
+
sudo ip addr add dev "${INTERNAL_BRIDGE_NAME}""${INTERNAL_BRIDGE_ADDRESS}/${INTERNAL_BRIDGE_SIZE}" broadcast "${INTERNAL_BRIDGE_BROADCAST}"
0 commit comments