Welcome to the Red Hat OpenShift Virtualization Roadshow

This roadshow event is organized to allow you to have a hands-on experience with Red Hat® OpenShift® Virtualization. It explores many common management activities that virtualization administrators often encounter in their day to day workflows.

This roadshow event is organized to allow you to have a hands-on experience with Red Hat® OpenShift® Virtualization. It explores many common management activities that virtualization administrators often encounter in their day to day workflows.

Template and InstanceType management

20 mins

Pre-configured Red Hat virtual machine templates are listed in the VirtualizationTemplates page. These templates are available for different versions of Red Hat Enterprise Linux®, Fedora, CentOS, Microsoft Windows Desktop, and Microsoft Windows Server editions. Each Red Hat virtual machine template is preconfigured with an operating system image, the default settings for the operating system, the flavor (CPU and memory), and the workload type (server).

The Templates page displays four types of virtual machine templates:

  • Red Hat Supported templates are fully supported by Red Hat.

  • User Supported templates are Red Hat Supported templates that were cloned and created by users.

  • Red Hat Provided templates have limited support from Red Hat.

  • User Provided templates are Red Hat Provided templates that were cloned and created by users.


What will you learn?

  • How to create Templates or define InstanceTypes to ease deployment operations. 

What do you need before starting?

  • Completed the previous resources in this learning path.

Clone and customize a template

By default pre-configured templates provided by Red Hat OpenShift Virtualization cannot be customized. However you can clone a template and make adjustments to it for your particular workload in order to make it easier to request specific types of virtual machines for specific workloads. In this section of the lab we are going to do just this, by creating a template that will provide a database server on demand for our end users.

  1. To begin, navigate to VirtualizationTemplates and select All projects (Figure 1).

    01 Template List
    Figure 1

     

  2. In the search bar type in centos9 and in the list of templates that appear find the template for centos-stream9-server-large (Figure 2).

    02 Search Centos9
    Figure 2

     

  3. Select the three-dot menu to the far right, and click on the option to Clone from the menu that pops out (Figure 3).

    03 Clone Template
    Figure 3

     

  4. A new menu called Clone template will appear, fill in the the following values, and when finished click on the Clone button (Figure 4).
    1. Template name: centos-stream9-server-db-xl

    2. Template project: vmexamples

    3. Template display name: CentOS Stream 9 VM - Database XL Template

      04 Clone Template Options
      Figure 4

       

  5. This will take you to the Details page for the template where we will be able to customize some options. Start by finding the CPU and Memory near the bottom of the page, and click on the pencil icon to edit it (Figure 5).

    05 Clone Details
    Figure 5

     

  6. A new window will pop out where you can edit the amount of CPU and Memory. For our XL template set the value of CPUs to 4, and Memory to 16 GiB, and click the Save button (Figure 6).

    06 Edit CPU Mem
    Figure 6

     

  7. Navigate to the Network Interfaces tab, to the right of the default interface, select the three-dot menu and the edit option (Figure 7).

    07 Edit Network
    Figure 7

     

  8. When the Edit network interface menu appears, set the Network value to the vmexamples/vlan0 network, and click the Save button (Figure 8).

    08 Edit Net Int
    Figure 8

     

  9. Next click on the Scripts tab at the top, and in the section called Cloud-init click the Edit button (Figure 9).

    09 Scripts CloudInit
    Figure 9

     

  10. When the Cloud-init dialog opens, click the radio button to Configure via: Script then add the following YAML snippet to the end of the script (Figure 10).

      packages:
        - mariadb-server
      runcmd:
        - systemctl enable mariadb
        - systemctl start mariadb
    10 Cloud Init Script
    Figure 10

     

  11. Click the Save button, followed by the Apply button.

  12. Now click on the Virtualization → Catalog menu on the left, select the Template catalog option and click on User templates. You should see our created template available as a tile (Figure 11).

    11 User Templates
    Figure 11

     

  13. Click on the tile and you will be prompted with the VM startup screen. Click the Quick create VirtualMachine button (Figure 12).

    12 Quick Create Template
    Figure 12

     

  14. When the virtual machine boots you can see on the Overview page that it was created from our template, and has the system resources we defined, and is already attached to the vmexamples/vlan0 network with an assigned IP address (Figure 13).

    13 VM From Template
    Figure 13

     

  15. Click on the Console tab at the top and use the Guest login credentials option to login to the console of the virtual machine (Figure 14).

    14 VM Console
    Figure 14

     

  16. Once you are logged into the virtual machine, run the following command to test the install of MariaDB (Figure 15).

    sudo mysql -u root
    15 MariaDB Login
    Figure 15

     

Create a Windows VM template

In this segment of our lab, we will install Microsoft Windows Server 2019 using an ISO hosted on a web server. This represents one way to install an operating system to a virtual machine that takes advantage of the ability to source disks from many locations, including a web server, object storage, or other persistent volumes in the cluster.

This process can be streamlined after the initial operating system installation by creating a template from the virtual machine. The specific process for preparing the guest operating system to be used as a template will vary, be sure to follow your organization’s guidelines and requirements when preparing a template OS.
 

  1. From the left menu, navigate to VirtualizationCatalog, and click on the Template catalog tab near the top (Figure 16).

    16 Template Catalog
    Figure 16

     

  2. Scroll down until you find the Microsoft Windows Server 2019 VM tile (Figure 17).

    17 Windows 2k19 Tile
    Figure 17

     

  3. A dialog will appear showing the default configuration related to the template (Figure 18).


    Note: Notice that there is intially no option to quick create this VM, and we must customize the VM to fit our needs.

     

    18 Windows 2k19 Dialog
    Figure 18

     

  4. In this dialog (Figure 19):

    1. Specify the name windows

    2. Enable the checkbox Boot from CD

    3. Choose URL (creates PVC) from the drop-down menu

    4. Specify the url: http://192.168.123.100:81/Windows2019.iso

    5. Reduce the CD disk size to 5 GiB

    6. Keep the Disk source size disk to the default value 60 GiB

    7. Ensure the Mount Windows drivers disk checkbox is enabled. This is required to install Windows systems, which will provide the drivers for VirtIO.

      19 Windows 2k19 Parameters
      Figure 19

       

  5. With the options filled out, we want to click on the Customize VirtualMachine button at the bottom to continue configuring our Template.

  6. On the Customize and create VirtualMachine screen, click on the *Scripts tab, and then scroll down to the Sysprep section and click on the Edit button (Figure 20).

    20 Customize Scripts
    Figure 20

     

  7. A new window will pop up for you to create Sysprep actions for your new template (Figure 21).

    21 Sysprep
    Figure 21

     

  8. Copy and paste the following code block into the autounattend.xml section:

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-microsoft-com:unattend">
      <settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <DiskConfiguration>
            <Disk wcm:action="add">
              <CreatePartitions>
                <CreatePartition wcm:action="add">
                  <Order>1</Order>
                  <Extend>true</Extend>
                  <Type>Primary</Type>
                </CreatePartition>
              </CreatePartitions>
              <ModifyPartitions>
                <ModifyPartition wcm:action="add">
                  <Active>true</Active>
                  <Format>NTFS</Format>
                  <Label>System</Label>
                  <Order>1</Order>
                  <PartitionID>1</PartitionID>
                </ModifyPartition>
              </ModifyPartitions>
              <DiskID>0</DiskID>
              <WillWipeDisk>true</WillWipeDisk>
            </Disk>
          </DiskConfiguration>
          <ImageInstall>
            <OSImage>
              <InstallFrom>
                <MetaData wcm:action="add">
                  <Key>/IMAGE/NAME</Key>
                  <Value>Windows Server 2019 SERVERSTANDARD</Value>
                </MetaData>
              </InstallFrom>
              <InstallTo>
                <DiskID>0</DiskID>
                <PartitionID>1</PartitionID>
              </InstallTo>
            </OSImage>
          </ImageInstall>
          <UserData>
            <AcceptEula>true</AcceptEula>
            <FullName>Administrator</FullName>
            <Organization>My Organization</Organization>
          </UserData>
          <EnableFirewall>false</EnableFirewall>
        </component>
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <SetupUILanguage>
            <UILanguage>en-US</UILanguage>
          </SetupUILanguage>
          <InputLocale>en-US</InputLocale>
          <SystemLocale>en-US</SystemLocale>
          <UILanguage>en-US</UILanguage>
          <UserLocale>en-US</UserLocale>
        </component>
      </settings>
      <settings pass="offlineServicing">
        <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <EnableLUA>false</EnableLUA>
        </component>
      </settings>
      <settings pass="specialize">
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <AutoLogon>
            <Password>
              <Value>R3dh4t1!</Value>
              <PlainText>true</PlainText>
            </Password>
            <Enabled>true</Enabled>
            <LogonCount>999</LogonCount>
            <Username>Administrator</Username>
          </AutoLogon>
          <OOBE>
            <HideEULAPage>true</HideEULAPage>
            <HideLocalAccountScreen>true</HideLocalAccountScreen>
            <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
            <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
            <NetworkLocation>Work</NetworkLocation>
            <ProtectYourPC>3</ProtectYourPC>
            <SkipMachineOOBE>true</SkipMachineOOBE>
          </OOBE>
          <UserAccounts>
            <LocalAccounts>
              <LocalAccount wcm:action="add">
                <Description>Local Administrator Account</Description>
                <DisplayName>Administrator</DisplayName>
                <Group>Administrators</Group>
                <Name>Administrator</Name>
              </LocalAccount>
            </LocalAccounts>
          </UserAccounts>
          <TimeZone>Eastern Standard Time</TimeZone>
        </component>
      </settings>
      <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <InputLocale>en-US</InputLocale>
          <SystemLocale>en-US</SystemLocale>
          <UILanguage>en-US</UILanguage>
          <UserLocale>en-US</UserLocale>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
          <AutoLogon>
            <Password>
              <Value>R3dh4t1!</Value>
              <PlainText>true</PlainText>
            </Password>
            <Enabled>true</Enabled>
            <LogonCount>999</LogonCount>
            <Username>Administrator</Username>
          </AutoLogon>
          <OOBE>
            <HideEULAPage>true</HideEULAPage>
            <HideLocalAccountScreen>true</HideLocalAccountScreen>
            <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
            <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
            <NetworkLocation>Work</NetworkLocation>
            <ProtectYourPC>3</ProtectYourPC>
            <SkipMachineOOBE>true</SkipMachineOOBE>
          </OOBE>
          <UserAccounts>
            <LocalAccounts>
              <LocalAccount wcm:action="add">
                <Description>Local Administrator Account</Description>
                <DisplayName>Administrator</DisplayName>
                <Group>Administrators</Group>
                <Name>Administrator</Name>
              </LocalAccount>
            </LocalAccounts>
          </UserAccounts>
          <TimeZone>Eastern Standard Time</TimeZone>
        </component>
      </settings>
    </unattend>
  9. Once the code is pasted, click the Save button on the dialog (Figure 22).

    22 Windows 2k19 Sysprep
    Figure 22

     

  10. You will be returned to the Customize and create Virtual Machine screen, Click on the Disks tab, and locate the line for the installation-CDROM, click the three-dot menu on the right, and select Edit (Figure 23).

    23 Edit Boot Media
    Figure 23

     

  11. Select the option for Use this disk as a boot source, and click on the Save button at the bottom (Figure 24).

    24 Boot Source
    Figure 24

     

  12. When you return to the Disks tab, click on the Create VirtualMachine button at the bottom.

  13. The Virtual Machine will start the provisioning process by downloading the ISO image, configuring, and starting the instance (Figure 25).

    25 Windows 2k19 Provisioning
    Figure 25

     

  14. After a few minutes, the Virtual VM will be in Running status. Switch to the Console tab (Figure 26):

    26 Windows 2k19 Console
    Figure 26



    Important: The VM is marked as "Not migratable" because a CD-ROM disk is attached.

     

  15. Once the VM installation process is complete, go ahead and power it off with the stop button. We can now take a snapshot of the root disk, and use that to create a bootable volume template that we can use to boot other Windows 2k19 machines.

  16. Click on StoragePersistentVolumeClaims to see a list of PVCs available in the vmexamples namespace (Figure 27).

    27 Windows PVC
    Figure 27

     

  17. Find the windows PVC that is listed and using the three-dot menu on the right select Clone PVC. On the menu that pops up, name the new PVC windows-2k19-template. Click the Clone button to continue (Figure 28).

    28 Clone Windows PVC
    Figure 28

     

  18. Once this is saved, you can return to the Virtualization → Catalog menu, and use this cloned PVC as a future boot source for creating new Virtual Machines by selecting the option for PVC (clone PVC) as the Disk source, and selecting the Windows-2k19-Template PVC as the PVC name to clone (Figure 29).

    29 Windows Template
    Figure 29

     

Introduction to Instance Types

In order to simplify the deployment process for virtual machines, starting with OpenShift 4.14 the default configuration mechanism was changed to emphasize the use of Instance Types. An instance type is a reusable object where you can define resources and characteristics to apply to a new VM. You can define custom instance types or use the variety that are included when you install OpenShift Virtualization when provisioning your own VM. This section explores provisioning a VM using an instance type.

  1. To get started click on VirtualizationCatalog on the left-side menu. You will see the default catalog item is InstanceType (Figure 30).

    30 Left Menu Catalog
    Figure 30

     

  2. The first step to using an instance type is to select a volume to boot from. Similar to the templates that provide boot sources, those boot sources are available to use for an instance type, or you can upload your own with the Add volume button.

  3. Click on rhel9 to create a VM with that boot source (Figure 31).

    31 Volume Boot
    Figure 31

     

  4. Next you can select the instance type you would like to use. There are Red Hat provided instance types by default, or you can create your own. If you hover over a provided instance type you can see a description of it’s intended use (Figure 32).

    32 Select InstanceType
    Figure 32

     

    1. The Red Hat provided instance types are intended for the following use cases:
      1. cx1: Intended for compute intensive workloads

      2. u1: The most general and "universal" workloads

      3. gn1: Dedicated for VMs making use of the nVidia GPU operator.

      4. n1: Designed for network intensive workloads like VNF

      5. m1: Designed for memory intensive workloads.

  5. Click on the U series tile to see a dropdown list of defined resources for general instance types. The default option here is medium: 1 CPUs, 4 GiB Memory. Select it (Figure 33).

    33 InstanceType Resources
    Figure 33

     

  6. The last section that needs to be completed to provision using an instance type is similar to the template section. You need to provide a name for the virtual machine, and select the storage class to be used for a backing disk. By default, a name will be generated for the VM, and the default virtualization storage class will be selected. When you are satisfied, click the Create VirtualMachine button (Figure 34).

    34 VM Details
    Figure 34

     

  7. You will be directed to the virtual machine overview page, and see that the VM provisioned using an instance type is now up and running (Figure 35).

    35 VM Overview
    Figure 35

Summary

In this section we learned how to clone and customize an existing template to create one that can be used for specific workloads like databases. We also learned how to configure one of the existing Windows templates that exists without a boot source, and automate it’s installation process, so we can create future templates by cloning the installation PVC that is created with that VM. We also introduced how to make use of instance types to further customize our virtual machines for specific workloads.

Previous resource
Network management
Next resource
Working with virtual machines and applications

This learning path is for operations teams or system administrators

Developers may want to check out Foundations of OpenShift on developers.redhat.com. 

Get started on developers.redhat.com

Hybrid Cloud Logo LinkedIn YouTube Facebook Twitter

Products

Tools

Try, buy, sell

Communicate

About Red Hat

We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.