Creating and using boot sources

About virtual machines and boot sources

Virtual machines consist of a virtual machine definition and one or more disks that are backed by data volumes. Virtual machine templates enable you to create virtual machines using predefined virtual machine specifications.

Every virtual machine template requires a boot source, which is a fully configured virtual machine disk image including configured drivers. Each virtual machine template contains a virtual machine definition with a pointer to the boot source. Each boot source has a predefined name and namespace. For some operating systems, a boot source is automatically provided. If it is not provided, then an administrator must prepare a custom boot source.

To use the boot sources feature, install the latest release of OKD Virtualization. The namespace openshift-virtualization-os-images enables the feature and is installed with the OKD Virtualization Operator. Once the boot source feature is installed, you can create boot sources, attach them to templates, and create virtual machines from the templates.

Define a boot source by using a persistent volume claim (PVC) that is populated by uploading a local file, cloning an existing PVC, importing from a registry, or by URL. Attach a boot source to a virtual machine template by using the web console. After the boot source is attached to a virtual machine template, you create any number of fully configured ready-to-use virtual machines from the template.

Importing a Red Hat Enterprise Linux image as a boot source

You can import a Red Hat Enterprise Linux (RHEL) image as a boot source by specifying the URL address for the image.

Prerequisites

  • You must have access to the web server with the operating system image. For example: Red Hat Enterprise Linux web page with images.

Procedure

  1. In the OKD Virtualization console, click WorkloadsVirtualization from the side menu.

  2. Click the Templates tab.

  3. Identify the RHEL template for which you want to configure a boot source and click Add source.

  4. In the Add boot source to template window, select Import via URL (creates PVC) from the Boot source type list.

  5. Click RHEL download page to access the Red Hat Customer Portal. A list of available installers and images is displayed on the Download Red Hat Enterprise Linux page.

  6. Identify the Red Hat Enterprise Linux KVM guest image that you want to download. Right-click Download Now, and copy the URL for the image.

  7. In the Add boot source to template window, paste the copied URL of the guest image into the Import URL field, and click Save and import.

Verification

To verify that a boot source was added to the template:

  1. Click the Templates tab.

  2. Confirm that the tile for this template displays a green checkmark.

You can now use this template to create RHEL virtual machines.

Adding a boot source for a virtual machine template

A boot source can be configured for any virtual machine template that you want to use for creating virtual machines or custom templates. When virtual machine templates are configured with a boot source, they are labeled Available in the Templates tab. After you add a boot source to a template, you can create a new virtual machine from the template.

There are four methods for selecting and adding a boot source in the web console:

  • Upload local file (creates PVC)

  • Import via URL (creates PVC)

  • Clone existing PVC (creates PVC)

  • Import via Registry (creates PVC)

Prerequisites

  • To add a boot source, you must be logged in as a user with the os-images.kubevirt.io:edit RBAC role or as an administrator. You do not need special privileges to create a virtual machine from a template with a boot source added.

  • To upload a local file, the operating system image file must exist on your local machine.

  • To import via URL, access to the web server with the operating system image is required. For example: the Red Hat Enterprise Linux web page with images.

  • To clone an existing PVC, access to the project with a PVC is required.

  • To import via registry, access to the container registry is required.

Procedure

  1. In the OKD Virtualization console, click WorkloadsVirtualization from the side menu.

  2. Click the Templates tab.

  3. Identify the virtual machine template for which you want to configure a boot source and click Add source.

  4. In the Add boot source to template window, click Select boot source, select a method for creating a persistent volume claim (PVC): Upload local file, Import via URL, Clone existing PVC, or Import via Registry.

  5. Optional: Click This is a CD-ROM boot source to mount a CD-ROM and use it to install the operating system on to an empty disk. The additional empty disk is automatically created and mounted by OKD Virtualization. If the additional disk is not needed, you can remove it when you create the virtual machine.

  6. Enter a value for Persistent Volume Claim size to specify the PVC size that is adequate for the uncompressed image and any additional space that is required.

    1. Optional: Enter a name for Source provider to associate the name with this template.

    2. Optional: Advanced Storage settings: Click Storage class and select the storage class that is used to create the disk. Typically, this storage class is the default storage class that is created for use by all PVCs.

    3. Optional: Advanced Storage settings: Click Access mode and select an access mode for the persistent volume:

      • Single User (RWO) mounts the volume as read-write by a single node.

      • Shared Access (RWX) mounts the volume as read-write by many nodes.

      • Read Only (ROX) mounts the volume as read-only by many nodes.

    4. Optional: Advanced Storage settings: Click Volume mode if you want to select Block instead of the default value Filesystem. OKD Virtualization can statically provision raw block volumes. These volumes do not have a file system, and can provide performance benefits for applications that either write to the disk directly or implement their own storage service.

  7. Select the appropriate method to save your boot source:

    1. Click Save and upload if you uploaded a local file.

    2. Click Save and import if you imported content from a URL or the registry.

    3. Click Save and clone if you cloned an existing PVC.

Your custom virtual machine template with a boot source is listed in the Templates tab, and you can create virtual machines by using this template.

Creating a virtual machine from a template with an attached boot source

After you add a boot source to a template, you can create a new virtual machine from the template.

Procedure

  1. In the OKD web console, click Workloads > Virtualization in the side menu.

  2. From the Virtual Machines tab or the Templates tab, click Create and select Virtual Machine with Wizard.

  3. In the Select a template step, select an OS from the Operating System list that has the (Source available) label next to the OS and version name. The (Source available) label indicates that a boot source is available for this OS.

  4. Click Review and Confirm.

  5. Review your virtual machine settings and edit them, if required.

  6. Click Create Virtual Machine to create your virtual machine. The Successfully created virtual machine page is displayed.

Creating a custom boot source

You can prepare a custom disk image, based on an existing disk image, for use as a boot source.

Use this procedure to complete the following tasks:

  • Preparing a custom disk image

  • Creating a boot source from the custom disk image

  • Attaching the boot source to a custom template

Procedure

  1. In the OKD Virtualization console, click Workloads > Virtualization from the side menu.

  2. Click the Templates tab.

  3. Click the link in the Source provider column for the template you want to customize. A window displays, indicating that the template currently has a defined source.

  4. In the window, click the Customize source link.

  5. Click Continue in the About boot source customization window to proceed with customization after reading the information provided about the boot source customization process.

  6. On the Prepare boot source customization page, in the Define new template section:

    1. Select the New template namespace field and then choose a project.

    2. Enter the name of the custom template in the New template name field.

    3. Enter the name of the template provider in the New template provider field.

    4. Select the New template support field and then choose the appropriate value, indicating support contacts for the custom template you create.

    5. Select the New template flavor field and then choose the appropriate CPU and memory values for the custom image you create.

  7. In the Prepare boot source for customization section, customize the cloud-init YAML script, if needed, to define login credentials. Otherwise, the script generates default credentials for you.

  8. Click Start Customization. The customization process begins and the Preparing boot source customization page displays, followed by the Customize boot source page. The Customize boot source page displays the output of the running script. When the script completes, your custom image is available.

  9. In the VNC console, click show password in the Guest login credentials section. Your login credentials display.

  10. When the image is ready for login, sign in with the VNC Console by providing the user name and password displayed in the Guest login credentials section.

  11. Verify the custom image works as expected. If it does, click Make this boot source available.

  12. In the Finish customization and make template available window, select I have sealed the boot source so it can be used as a template and then click Apply.

  13. On the Finishing boot source customization page, wait for the template creation process to complete. Click Navigate to template details or Navigate to template list to view your customized template, created from your custom boot source.

Additional resources