Skip to content

Latest commit

 

History

History
234 lines (172 loc) · 8.85 KB

provisioning-devices.md

File metadata and controls

234 lines (172 loc) · 8.85 KB

Provisioning Devices

This section describes how to provision an OS image or disk image to a physical or virtual device, depending on your target environment.

Testing an OS image on a developer machine

You can inspect the content of your bootc OS image by running the following command, which starts a container with an interactive shell:

podman run -it --rm <your_bootc_image> bash

For testing, you can also "boot" the OS image in the sense of running a container that launches systemd, which is the default for bootc images if you do not specify a command to run explicitly.

Important

  • This does not boot the kernel inside the image but relies on the host kernel.
  • Expect that not all services start and run correctly when containerized and without full system access. They may still run correctly when deployed on a physical or virtual machine.
  • Do not run the container --privileged without restrictions, as services inside the container may interfere with the host (see the bootc documentation).

Start the container by running the following command:

sudo podman run -it --rm --name=my-bootc-container \
  --hostname=my-bootc-host \
  --privileged -v /sys:/sys:ro --userns=auto \
  <your_bootc_image>

You will see the messages generated by the systemd services starting up and typically end up at a login prompt. To detach from the console, type <ctrl+p> and <ctrl+q> in sequence.

You can exec into the running container by running:

sudo podman exec -it my-bootc-container bash

Provisioning Physical Devices

After building an ISO disk image from an OS image (bootc) by using bootc-image-builder tool, the resulting image is a system similar to the RHEL ISOs available for download, except that your OS image content is embedded in the ISO disk image. You do not need to have access to the network during installation. You can install the resulting ISO disk image to a bare metal system. See Building and Publishing OS Images and Disk Images.

Prerequisites

  • You have created an ISO disk image with your bootc image embedded.

To provision a physical device from that ISO disk image, perform the following steps:

  • Copy your ISO disk image to a USB flash drive.

  • Install your physical device from the USB flash drive.

For installing the ISO over the network, see the RHEL documentation.

Provisioning on Red Hat OpenShift Virtualization

You can provision a virtual machine on OpenShift Virtualization from a QCoW2 disk image hosted on an OCI container registry (see Image Building for OpenShift Virtualization).

If your OS image does not already contain the agent enrollment configuration, you can inject this configuration through cloud-init user data at provisioning-time (late binding).

Prerequisites:

  • You have installed the Flight Control flightctl CLI and logged in to your Flight Control service instance.
  • You have installed the OpenShift oc CLI, used it to log in to your OpenShift cluster instance, and have changed to the project in which you want to create your VM.

To create the cloud-init configuration, perform the following steps:

  • Request a new agent enrollment configuration, storing it in a file called "config.yaml":

    flightctl certificate request --signer=enrollment --expiration=365d --output=embedded > config.yaml
  • Create cloud config user data file called "cloud-config.yaml" that places the agent configuration in the right location on first boot:

    cat << END > cloud-config.yaml
    #cloud-config
    write_files:
    - path: /etc/flightctl/config.yaml
      content: $(cat config.yaml | base64 -w0)
      encoding: b64
    END
  • Finally, create a Kubernetes Secret that contains this cloud config user data file:

    oc create secret generic enrollment-secret --from-file=userdata=cloud-config.yaml

To create a virtual machine that has its primary disk populated from your QCoW2 container disk image and a cloud-init config drive populated from your enrollment secret, perform the following steps:

  • Create a file containing a virtual machine resource manifest following this example:

    cat << END > my-bootc-vm.yaml
    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: my-bootc-vm
    spec:
      runStrategy: RerunOnFailure
      template:
        spec:
          domain:
            cpu:
              cores: 1
            memory:
              guest: 1024M
            devices:
              disks:
                - name: containerdisk
                  disk:
                    bus: virtio
                - name: cloudinitdisk
                  disk:
                    bus: virtio
          volumes:
            - name: containerdisk
              containerDisk:
                image: <your_container_disk_repo_and_tag>
            - name: cloudinitdisk
              cloudInitConfigDrive:
                secretRef:
                  name: enrollment-secret
    END
  • Apply this resource manifest to your cluster:

    oc apply -f my-bootc-vm.yaml

Provisioning on VMware vSphere

You can provision a virtual machine on VMware vSphere from a VMDK disk image (see Image Building for VMware vSphere). See this blog post for a detailed explanation integrating a VMDK produced from OS images into vSphere.

If your OS image does not already contain the agent enrollment configuration, you can inject this configuration through cloud-init user data at provisioning-time (late binding).

Prerequisites:

  • You have installed the Flight Control flightctl CLI and logged in to your Flight Control service instance.
  • You have installed the VMware govc CLI and logged in to your remote vSphere environment (see the installation guide).
  • You have built a VMDK disk image called "disk.vmdk" and have it available on the machine running the following commands.

To create the cloud-init configuration, perform the following steps:

  • Request a new agent enrollment configuration, storing it in a file called "config.yaml":

    flightctl certificate request --signer=enrollment --expiration=365d --output=embedded > config.yaml
  • Create cloud config user data file called "cloud-config.yaml" that places the agent configuration in the right location on first boot:

    cat <<EOF > cloud-config.yaml
    #cloud-config
    write_files:
    - path: /etc/flightctl/config.yaml
      content: $(cat config.yaml | base64 -w0)
      encoding: b64
    EOF

To upload your VMDK disk image and create a virtual machine from it, perform the following steps:

  • Upload the disk.vmdk file to a desired directory in vSphere.

    govc import.vmdk \
      -dc="${DATACENTER}" -ds="${DATASTORE}" -pool="${DATACENTER_POOL}" \
      disk.vmdk ${DESTINATION_FOLDER}
  • Confirm the file has been uploaded by listing files within the datastore directory.

    govc datastore.ls \
      -dc="${DATACENTER}" -ds="${DATASTORE}" \
      ${DESTINATION_FOLDER}

    You should see two files, "disk.vmdk" and "disk-flat.vmdk".

  • Create the virtual machine.

    govc vm.create \
      -dc="${DATACENTER}" \
      -ds="${DATASTORE}" \
      -pool="${DATACENTER_POOL}" \
      -net="${NETWORK}" \
      -disk.controller=pvscsi \
      -on=false \
      -c=1 -m=1024 \
      -g="rhel9_64Guest" \
      -firmware="${FIRMWARE}" \
      my-bootc-vm
  • Copy the uploaded disk to the folder of the VM you created.

    govc datastore.cp \
      -ds=${DATASTORE} ${DESTINATION_FOLDER}/disk.vmdk my-bootc-vm/disk.vmdk
  • Attach the VMDK disk image to the newly created virtual machine.

    govc vm.disk.attach \
      -dc="${DATACENTER}" -ds="${DATASTORE}" \
      -link=false \
      -vm="my-bootc-vm" \
      -disk="my-bootc-vm/disk.vmdk"
  • Attach the cloud-init user data to the virtual machine.

    govc vm.change \
      -dc="${DATACENTER}" \
      -vm="my-bootc-vm" \
      -e guestinfo.userdata="$(gzip -c9 <cloud-config.yaml | { base64 -w0 2>/dev/null || base64; })" \
      -e guestinfo.userdata.encoding="gzip+base64"
  • Power on the virtual machine.

    govc vm.power -dc="${DATACENTER}" -on=true my-bootc-vm