Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pxe-on-vm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant
*~
25 changes: 25 additions & 0 deletions pxe-on-vm/README.md
Original file line number Diff line number Diff line change
@@ -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.

<img src="network.png" />

It is important to manually configure the bridged network on pxe-vm to
the *promiscuous mode*.
9 changes: 9 additions & 0 deletions pxe-on-vm/boot-tester-vm/Vagrantfile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions pxe-on-vm/network.dot
Original file line number Diff line number Diff line change
@@ -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];
}
Binary file added pxe-on-vm/network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions pxe-on-vm/pxe-vm/Vagrantfile
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions pxe-on-vm/pxe-vm/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.11 192.168.2.249;
option routers 192.168.2.1;
option broadcast-address 192.168.2.255;
option domain-name-servers 8.8.8.8;
}

next-server 192.168.2.10;
filename "pxelinux.0";
EOF

service isc-dhcp-server restart