diff --git a/Dockerfile b/Dockerfile index 684e82dd..1614d0af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ -FROM busybox:latest +FROM alpine:latest MAINTAINER Dalton Hubble -ADD bin/server /bin/server - -EXPOSE 8081 -CMD ./bin/server +COPY bin/server /server +EXPOSE 8080 +CMD ["./server"] diff --git a/Makefile b/Makefile index 5ab27a0d..49da0702 100644 --- a/Makefile +++ b/Makefile @@ -4,24 +4,21 @@ build: ./build -docker-build: - docker build --rm=true -t dghubble.io/metapxe . +build-docker: + ./docker-build -aci-build: +build-aci: ./acifile run-docker: - docker run -p 8081:8081 -v $(shell echo $$PWD)/static:/static dghubble.io/metapxe:latest + docker run -p 8080:8080 --name=bcs -v $(shell echo $$PWD)/static:/static dghubble/bcs:latest run-rkt: - rkt --insecure-options=image run --no-overlay bin/metapxe-0.0.1-linux-amd64.aci + rkt --insecure-options=image run --no-overlay bin/bcs-0.0.1-linux-amd64.aci run-pixiecore: - docker run -v $(shell echo $$PWD)/static:/static danderson/pixiecore -api http://172.17.0.2:8081/ + ./scripts/pixiecore run-dhcp: ./scripts/vethdhcp - - - diff --git a/README.md b/README.md index 2fc3b371..357f10e3 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,26 @@ -Boot and cloud config service for PXE, iPXE, and Pixiecore. +# Boot Config Service + +Boot config service for PXE, iPXE, and Pixiecore. ## Validation -The config service can be validated in scenarios which use PXE, iPXE, or Pixiecore on a libvirt virtual network or on a physical network of bare metal machines. +The boot config service can be validated in PXE, iPXE, and Pixiecore scenarios using a libvirt virtual network with VM or bare metal PXE clients. -### libvirt - -A libvirt virtual network of containers and VMs can be used to validate PXE booting of VM clients in various scenarios (PXE, iPXE, Pixiecore). - -To do this, start the appropriate set of containered services for the scenario, then boot a VM configured to use the PXE boot method. - -Docker starts containers with virtual ethernet connections to the `docker0` bridge +An ethernet bridge can be used to connect container services and VM or bare metal boot clients on the same network. Docker starts containers with virtual ethernet connections to the `docker0` bridge $ brctl show $ docker network inspect bridge # docker client names the bridge "bridge" -which uses the default subnet 172.17.0.0/16. It is also possible to create your own network bridge and reconfigure Docker to start containers on that bridge, but that approach is not used here. +which uses the default subnet 172.17.0.0/16. Rather than reconfiguring Docker to start containers on a user defined bridge, it is easier to attach VMs and bare metal machines to `docker0`. -PXE boot client VMs can be started within the same subnet by attaching to the `docker0` bridge. - -Create a VM using the virt-manager UI, select Network Boot with PXE, and for the network selection, choose "Specify Shared Device" with bridge name `docker0`. - -The VM should PXE boot using the boot config determined by the MAC address of the virtual network card which can be inspected in virt-manager. +Start the container services specific to the scenario you wish to test, following the sections on PXE, iPXE, and Pixiecore below. Then create a client. ### iPXE #### Pixecore -Run the config service container. +Run the boot config service container. make run-docker @@ -42,3 +34,19 @@ Finally, run the `vethdhcp` to create a virtual ethernet connection on the `dock Create a PXE boot client VM using virt-manager as described above. Let the VM PXE boot using the boot config determined the MAC address to config mapping set in the config service. +## Clients + +Once boot services are running, create a PXE boot client VM or attach a bare metal machine to your host. + +### VM + +Create a VM using the virt-manager UI, select Network Boot with PXE, and for the network selection, choose "Specify Shared Device" with bridge name `docker0`. The VM should PXE boot using the boot configuration determined by its MAC address, which can be tweaked in virt-manager. + +### Bare Metal + +Link a bare metal machine, which has boot firmware (BIOS) support for PXE, to your host with a network adapter. Get the link and attach it to the bridge. + + ip link show # find new link e.g. enp0s20u2 + brctl addif docker0 enp0s20u2 + +Configure the boot firmware to prefer PXE booting or network booting and restart the machine. It should PXE boot using the boot configuration determined by its MAC address. diff --git a/acifile b/acifile index 7e37a583..9daf8199 100755 --- a/acifile +++ b/acifile @@ -1,13 +1,13 @@ #!/bin/bash -e acbuild begin -acbuild set-name dghubble.io/metapxe -acbuild copy bin/server /bin/server -acbuild set-exec /bin/server +acbuild set-name dghubble/bcs +acbuild copy bin/server /server +acbuild set-exec /server acbuild port add www tcp 8080 acbuild label add version 0.0.1 acbuild label add arch amd64 acbuild label add os linux acbuild annotation add authors "Dalton Hubble " -acbuild write bin/metapxe-0.0.1-linux-amd64.aci +acbuild write bin/bcs-0.0.1-linux-amd64.aci acbuild end \ No newline at end of file diff --git a/build b/build index f9dbd9f8..379fdfd3 100755 --- a/build +++ b/build @@ -3,9 +3,8 @@ # allow builds outside the standard GOPATH via symlink export GOPATH=${PWD}/Godeps/_workspace export GOBIN=${PWD}/bin - mkdir -p $GOPATH/src/github.com/coreos # directory or symlink must be present [ -d $GOPATH/src/github.com/coreos/coreos-baremetal ] || ln -s ${PWD} $GOPATH/src/github.com/coreos/coreos-baremetal -CGO_ENABLED=0 GOOS=linux go build -o bin/server -ldflags '-w' github.com/coreos/coreos-baremetal/cmd +CGO_ENABLED=0 GOOS=linux go build -o bin/server -a -tags netgo -ldflags '-w' github.com/coreos/coreos-baremetal/cmd diff --git a/cmd/main.go b/cmd/main.go index 58e14f7e..2acba954 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,14 +7,14 @@ import ( "github.com/coreos/coreos-baremetal/server" ) -const address = ":8081" +const address = ":8080" func main() { bootConfigProvider := server.NewBootConfigProvider() bootConfigProvider.Add(server.DefaultAddr, server.CoreOSBootConfig) srv := server.NewServer(bootConfigProvider) h := srv.HTTPHandler() - log.Printf("Starting coreos-baremetal metadata server") + log.Printf("Starting boot config server") err := http.ListenAndServe(address, h) if err != nil { log.Fatal("ListenAndServe: ", err) diff --git a/docker-build b/docker-build new file mode 100755 index 00000000..ed7bc14f --- /dev/null +++ b/docker-build @@ -0,0 +1,7 @@ +#!/bin/bash -e + +REPO=dghubble/bcs +GIT_SHA=$(git rev-parse HEAD) + +docker build -q --rm=true -t $REPO:$GIT_SHA . +docker tag -f $REPO:$GIT_SHA $REPO:latest \ No newline at end of file diff --git a/docker-push b/docker-push new file mode 100755 index 00000000..a54e4e40 --- /dev/null +++ b/docker-push @@ -0,0 +1,11 @@ +#!/bin/bash -e + +REPO=dghubble/bcs +QUAY_REPO=quay.io/dghubble/bcs +GIT_SHA=$(git rev-parse HEAD) + +# quay.io +docker tag $REPO:$GIT_SHA $QUAY_REPO:latest +docker tag $REPO:$GIT_SHA $QUAY_REPO:$GIT_SHA +docker push $QUAY_REPO:latest +docker push $QUAY_REPO:$GIT_SHA diff --git a/scripts/pixiecore b/scripts/pixiecore new file mode 100755 index 00000000..6d933ec3 --- /dev/null +++ b/scripts/pixiecore @@ -0,0 +1,11 @@ +#!/bin/bash -e + +CONFIG_SERVICE=bcs +CONFIG_SERVICE_IP=$(docker inspect --format {{.NetworkSettings.IPAddress}} ${CONFIG_SERVICE}) +CONFIG_SERVICE_PORT=$(docker inspect --format '{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort }}' ${CONFIG_SERVICE}) + +docker run -v $PWD/static:/static danderson/pixiecore -api http://$CONFIG_SERVICE_IP:$CONFIG_SERVICE_PORT/ + + + +