|
| 1 | + |
| 2 | +First, we can edit the `conf` file for the various env variables. |
| 3 | + |
| 4 | +# Images |
| 5 | + |
| 6 | +Next, we need to build the root fs: |
| 7 | + |
| 8 | +``` |
| 9 | +$ ./scripts/mkroot.sh |
| 10 | +``` |
| 11 | + |
| 12 | + |
| 13 | +After that, we install `kubeadm`: |
| 14 | +``` |
| 15 | +$ ./scripts/mkkubeadm.sh |
| 16 | +``` |
| 17 | + |
| 18 | +Next, build the images for the two vms: |
| 19 | +``` |
| 20 | +./scripts/mkkvm.sh 0 |
| 21 | +./scripts/mkkvm.sh 1 |
| 22 | +``` |
| 23 | + |
| 24 | +# Networking |
| 25 | + |
| 26 | +(Proper scripts to be added) |
| 27 | + |
| 28 | +There are multiple ways to setup networking. I opted for using a bridge device, |
| 29 | +and attach a NIC for all VMs there. (to be automated) |
| 30 | + |
| 31 | +``` |
| 32 | +# sudo ip link add kvm-br type bridge |
| 33 | +# sudo ip addr add 10.33.33.100/24 dev kvm-br |
| 34 | +``` |
| 35 | + |
| 36 | +And then, masquarade traffic from the VMs to the outside world |
| 37 | + |
| 38 | +``` |
| 39 | +# sudo sh -c 'echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables' |
| 40 | +# sudo modprobe br_netfilter |
| 41 | +# sudo sysctl -w net.ipv4.ip_forward=1 |
| 42 | +# sudo iptables -t nat -A POSTROUTING -o enxa0cec8e6e64c -j MASQUERADE |
| 43 | +# sudo iptables -A FORWARD -i enxa0cec8e6e64c -o kvm-br -m state --state RELATED,ESTABLISHED -j ACCEPT |
| 44 | +# sudo iptables -A FORWARD -i kvm-br -o enxa0cec8e6e64c -j ACCEPT |
| 45 | +``` |
| 46 | + |
| 47 | +I use a simple `dnsmasq.conf`: |
| 48 | + |
| 49 | +``` |
| 50 | +interface=kvm-br |
| 51 | +port=0 # no dns |
| 52 | +
|
| 53 | +dhcp-option=option:router,10.33.33.100 |
| 54 | +dhcp-option=option:dns-server,8.8.8.8 |
| 55 | +
|
| 56 | +dhcp-range=10.33.33.0,static |
| 57 | +dhcp-host=52:54:00:12:34:01,kvm1,10.33.33.1 |
| 58 | +dhcp-host=52:54:00:12:34:02,kvm2,10.33.33.2 |
| 59 | +
|
| 60 | +``` |
| 61 | + |
| 62 | +That I run in debug mode: |
| 63 | +``` |
| 64 | +sudo dnsmasq --conf-file=dnsmasq.conf -d |
| 65 | +``` |
| 66 | + |
| 67 | +# Kernel image |
| 68 | + |
| 69 | +The kernel image is expected to be in `KERNEL_SOURCE` in `conf`. Run |
| 70 | +`./scripts/installmods.sh` to install modules. |
| 71 | + |
| 72 | + |
| 73 | +# start vms |
| 74 | + |
| 75 | +``` |
| 76 | +./scripts/runkvm 0 |
| 77 | +``` |
| 78 | + |
| 79 | +``` |
| 80 | +./scripts/runkvm 1 |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | +# Notes |
| 85 | + |
| 86 | +`0` and `1` in `runkvm` and `mkkvm` scripts are used as indices to respective |
| 87 | +bash arrays. |
0 commit comments