diff --git a/pxe-on-vm/.gitignore b/pxe-on-vm/.gitignore new file mode 100644 index 0000000..60a9ff9 --- /dev/null +++ b/pxe-on-vm/.gitignore @@ -0,0 +1,2 @@ +.vagrant +*~ diff --git a/pxe-on-vm/README.md b/pxe-on-vm/README.md new file mode 100644 index 0000000..3db51ed --- /dev/null +++ b/pxe-on-vm/README.md @@ -0,0 +1,25 @@ +# PXE in VM + +I want to be able to test the auto-installation of Kubernetes cluster +on a VM cluster. To do this, I need to set up a PXE server in this VM +cluster and use it to boot other VMs. + +## VM DHCP Server + +To test that if a VM could be a DHCP server, I created two VMs -- +[pxe-vm](./pxe-vm) and [boot-tester-vm](./boot-tester-vm) on my +MacBook Pro using Vagrant. The pxe-vm's +[provisioning script](./pxe-vm/bootstrap.sh) configures a DHCP server. +This script is a script representation of steps listed in the PXE on +Raspberry Pi +[tutorial](https://github.com/k8sp/bare-metal-coreos/tree/master/pxe-on-rasppi). + +It is notable that both pxe-vm and boot-tester-vm have *bridged* +network, so logically, they connect directly to the LinkSys router. I +guess that I might be create a VirtualBox host-only network to mimic +the real LinkSys router. I might try that later. + + + +It is important to manually configure the bridged network on pxe-vm to +the *promiscuous mode*. diff --git a/pxe-on-vm/boot-tester-vm/Vagrantfile b/pxe-on-vm/boot-tester-vm/Vagrantfile new file mode 100644 index 0000000..66b28c1 --- /dev/null +++ b/pxe-on-vm/boot-tester-vm/Vagrantfile @@ -0,0 +1,9 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + + config.vm.box = "ubuntu/trusty64" + config.vm.network "public_network" + +end diff --git a/pxe-on-vm/network.dot b/pxe-on-vm/network.dot new file mode 100644 index 0000000..2891f14 --- /dev/null +++ b/pxe-on-vm/network.dot @@ -0,0 +1,12 @@ +graph G { + router [label="Linksys Router"]; + + subgraph clusterH { + label = "MacBook Pro"; + pxe_vm [label="PXE VM server"]; + boot_tester [label="Boot tester VM"]; + } + + pxe_vm -- router [label="bridged\npromiscuous mode", style=dotted]; + boot_tester -- router [label="bridged", style=dotted]; +} diff --git a/pxe-on-vm/network.png b/pxe-on-vm/network.png new file mode 100644 index 0000000..ba3ebe0 Binary files /dev/null and b/pxe-on-vm/network.png differ diff --git a/pxe-on-vm/pxe-vm/Vagrantfile b/pxe-on-vm/pxe-vm/Vagrantfile new file mode 100644 index 0000000..7350424 --- /dev/null +++ b/pxe-on-vm/pxe-vm/Vagrantfile @@ -0,0 +1,15 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/trusty64" + + config.vm.network "public_network", ip: "192.168.2.10" + + config.vm.provision "shell", path: "bootstrap.sh" + + config.vm.provider :virtualbox do |vb| + # enable promiscuous mode on the public network + vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"] + end +end diff --git a/pxe-on-vm/pxe-vm/bootstrap.sh b/pxe-on-vm/pxe-vm/bootstrap.sh new file mode 100644 index 0000000..1d70eb8 --- /dev/null +++ b/pxe-on-vm/pxe-vm/bootstrap.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +echo "Hello! Here we are going to configure this VM a PXE server for +booting CoreOS. This bootstraping script comes from +https://github.com/k8sp/bare-metal-coreos/tree/master/pxe-on-rasppi" + +apt-get update + +## DHCP Server +apt-get install -y isc-dhcp-server + +# Note that we don't edit /etc/network/interfaces as documented in +# https://github.com/k8sp/bare-metal-coreos/tree/master/pxe-on-rasppi, +# because in our Vagrantfile, we have +# +# config.vm.network "public_network", ip: "192.168.2.10" +# +# which sets the static IP 192.168.2.10 on the bridged NIC. + +cat > /etc/dhcp/dhcpd.conf <