Docker Community Forums

Share and learn in the Docker community.

PXE booting to a Docker Image - Windows - bare metal computer

Hi all,
I am not trying to run PXE inside a docker image. I am trying to boot to a pxe server, then select a docker image (that has an os and applications) and put that image on a bare metal machine. I’ve seen at least one Linux way to do this, but I am working in Windows. Any recommendations would be gratefully received.
Thanks,
Pres Brawner

As an administrator, you can boot a client over the network by first creating a NetworkAttachmentDefinition object for your PXE network. Then, reference the NetworkAttachmentDefinition in your virtual machine instance configuration file before you start the virtual machine instance. You can also specify a MAC address in the virtual machine instance configuration file, if required by the PXE server.

Prerequisites
A Linux bridge must be connected.

The PXE server must be connected to the same VLAN as the bridge.

Procedure
Configure a PXE network on the cluster:

Create the NetworkAttachmentDefinition file for PXE network pxe-net-conf:

apiVersion: “k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: pxe-net-conf
spec:
config: ‘{
“cniVersion”: “0.3.1”,
“name”: “pxe-net-conf”,
“plugins”: [
{
“type”: “cnv-bridge”,
“bridge”: “br1”
},
{
“type”: “cnv-tuning”
}
]
}’
The cnv-tuning plug-in provides support for custom MAC addresses.
The virtual machine instance will be attached to the bridge br1 through an access port with the requested VLAN.

Create the NetworkAttachmentDefinition object by using the file you created in the previous step:

$ oc create -f pxe-net-conf.yaml
Edit the virtual machine instance configuration file to include the details of the interface and network.

Specify the network and MAC address, if required by the PXE server. If the MAC address is not specified, a value is assigned automatically. However, note that at this time, MAC addresses assigned automatically are not persistent.

Ensure that bootOrder is set to 1 so that the interface boots first. In this example, the interface is connected to a network called :

interfaces:

  • masquerade: {}
    name: default
  • bridge: {}
    name: pxe-net
    macAddress: de:00:00:00:00:de
    bootOrder: 1
    Boot order is global for interfaces and disks.

Assign a boot device number to the disk to ensure proper booting after operating system provisioning.

Set the disk bootOrder value to 2:

devices:
disks:

  • disk:
    bus: virtio
    name: containerdisk
    bootOrder: 2
    Specify that the network is connected to the previously created NetworkAttachmentDefinition. In this scenario, is connected to the NetworkAttachmentDefinition called :

networks:

  • name: default
    pod: {}
  • name: pxe-net
    multus:
    networkName: pxe-net-conf
    Create the virtual machine instance:

$ oc create -f vmi-pxe-boot.yaml
virtualmachineinstance.kubevirt.io “vmi-pxe-boot” created
Wait for the virtual machine instance to run:

$ oc get vmi vmi-pxe-boot -o yaml | grep -i phase
phase: Running
View the virtual machine instance using VNC:

$ virtctl vnc vmi-pxe-boot
Watch the boot screen to verify that the PXE boot is successful.

Log in to the virtual machine instance:

$ virtctl console vmi-pxe-boot
Verify the interfaces and MAC address on the virtual machine and that the interface connected to the bridge has the specified MAC address. In this case, we used eth1 for the PXE boot, without an IP address. The other interface, eth0, got an IP address from OpenShift Container Platform.

$ ip addr

3. eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether de:00:00:00:00:de brd ff:ff:ff:ff:ff:ff

Thanks lewish95 for this very detailed reply. I will review.