My first container, learning and work in progress!
Forked from the nice work at jpetazzo/pxe.
When the container starts, it processes the pxe_hosts.json file, to create a dhcp_reservations and dhcp_options files for dnsmasq. pxelinux is configured to offer two config files, stable or beta, based on the channel you choose for your host.
It will also get the latest coreos release (stable and beta) and a pxelinux.0, if any of these files is not present on the data folder.
When the host boots, it will request a cloud-config file from this same container, provided by a python web server script running on port 8080.
That script gets the client private IP address of the request, and replaces the variables on the default.yaml file, or from a custom yaml template, (represented by a $<variable>
) for that host.
So you just have customise your default.yaml (or create multiple .yaml files if needed) for your hardware, and add hosts to your pxe_hosts.json.
As the original project, you need to setup on the host a bridge that has access to the pxe network, and then connect it to the container via pipework. If you see the default.yaml.sample file, the networking stuff there already sets a coreOS host with bridges in front of both ethernet interfaces of these IBM blades.
two options: git clone this repo:
$ git clone https://github.com/avlis/pxe_coreos pxe_coreos
$ cd pxe_coreos
or just download the Dockerfile.net into an empty folder (and rename it to Dockerfile):
$ mkdir pxe_coreos && cd pxe_coreos
$ wget https://github.com/avlis/pxe_coreos/Dockerfile.net -O Dockerfile
then:
$ docker build -t pxe_coreos .
make sure you have a proper default.yaml and a pxe_hosts.json file on your data folder! (in this example, it's in /home/core/pxe_coreos.data). Two samples are provided in this repo.
you can use a script similar to the one below (or the manage_pxe_container one) to start the container:
VLAN_ADDR=192.168.90.2
PXECID=$(docker run --cap-add NET_ADMIN -v /home/core/pxe_coreos.data:/cloudconfigserver/data -d pxe_coreos)
if [ -z "$PXECID" ]; then
echo something bad happened, container not launched.
exit 1
fi
sudo /home/core/pxe_coreos/bin/pipework br-internal $PXECID $VLAN_ADDR/24
check out the manage_pxe_container shell script on the utilites folder (on git, not on the container).
<ip>
to the url:
http://<ip of the container>:8080/?override_ipv4=<ip you want to check>
docker exec -it $PXECID /bin/sh /cloudconfigserver/bin/reconfig.sh
Get a coreos container up and ready for running pxe_coreos using this cloud config.
#cloud-config
coreos:
units:
- name: br-internal.netdev
runtime: true
content: |
[NetDev]
Name=br-internal
Kind=bridge
- name: eth0.network
runtime: true
content: |
[Match]
Name=eth0
[Network]
Bridge=br-internal
- name: br-internal.network
runtime: true
content: |
[Match]
Name=br-internal
[Network]
DNS=1.2.3.4
Address=10.0.2.2/24