PXE Booting/Kickstart - Container running dhcpd, tftpd and golang APIs
GoPXE is a dynamic build system for installing various operating systems on virtual machines and bare metal servers using pxe boot, tftp and dhcp wrapped into docker container orchestrated by APIs.
Download docker image
docker pull ppetko/gopxe
curl -s https://raw.githubusercontent.com/ppetko/GoPXE/master/conf/dhcpd.conf -b dhcpd.conf
curl -s https://raw.githubusercontent.com/ppetko/GoPXE/master/conf/tftpd.conf -b tftpd.conf
vi dhcpd.conf # and edit accordingly.
sudo docker run --rm --net=host --name goPXE -td \
--mount type=bind,source="$(pwd)"/dhcpd.conf,target=/etc/dhcp/dhcpd.conf \
--mount type=bind,source="$(pwd)"/tftpd.conf,target=/etc/xinetd.d/tftp \
ppetko/gopxe
go get github.com/ppetko/gopxe
cd $GOPATH/src/github.com/ppetko/gopxe
sudo make docker-build
Note: Parameters are specific to your environment.
curl -vv -H "Content-Type: application/json" -d \
'{
"default": "linux",
"label": "linux",
"menu": "centos7",
"kernel": "centos7/vmlinuz",
"ksdevice": "link",
"ip": "dhcp",
"load_ramdisk": "1",
"initrd":"centos7/initrd.img"
}' -X POST localhost:9090/bootaction/myfirstbootaction
curl -vv -H "Content-Type: application/json" -d \
'{
"bootaction": "myfirstbootaction",
"ksfile": "default",
"os": "centos-7",
"version": "7.5.1804",
"hostname": "test-myvm.local",
"uuid": "42330d5a-0ead-f7fa-4e3a-ae3bdcb08c69"
}' http://localhost:9090/pxeboot
curl -vv -H "Content-Type: application/json" -d \
'{
"bootaction": "vmtemplate",
"ksfile": "default",
"os": "centos-7",
"version": "7.5.1804",
"hostname": "test-myvm1.local",
"ip": "10.1.20.50",
"mask": "255.255.255.0",
"ns1": "8.8.8.8",
"ns2": "8.8.4.4",
"gw": "10.1.20.1",
"uuid": "42330d5a-0ead-f7fa-4e3a-ae3bdcb08c69"
}' http://localhost:9090/pxeboot
default linux
label linux
MENU LABEL centos7
KERNEL centos7/vmlinuz
APPEND ksdevice=link ip=dhcp load_ramdisk=1 initrd=centos7/initrd.img ks=http://localhost:9090/kickstart/?name=default&os=centos-7&version=7.5.1804&fqdn=test-myvm1.local&ip=10.1.20.50&mask=255.255.255.0&gw=255.255.255.0&ns1=8.8.8.8&ns2=8.8.4.4
# wget http://mirror.cc.columbia.edu/pub/linux/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso
# mkdir /mnt/iso
# mount -t iso9660 -o loop CentOS-7-x86_64-Minimal-1804.iso /mnt/iso/
sudo docker run --rm --net=host --name goPXE -td \
--mount type=bind,source="$(pwd)"/conf/dhcpd.conf,target=/etc/dhcp/dhcpd.conf \
--mount type=bind,source="$(pwd)"/conf/tftpd.conf,target=/etc/xinetd.d/tftp \
--mount type=bind,source="/mnt/iso/",target=/opt/localrepo \
ppetko/gopxe
If you'd like to contribute to the project, refer to the contributing documentation.