Skip to content

virt image documentation

Matthew Yee edited this page Jun 4, 2024 · 14 revisions

What is it?

An image of RHEL containing KVM is used for a subset of labs. In other words, virtual machines are nested in VMs provisioned in Instruqt for some labs.

Nested virtualization labs

This is a list of labs that currently use the virt image.

convert2rhel edge-management firewall-system-role networking-basics imagebuilder-service

Image creation process

  1. Create image in Insights Image Builder.

  2. Add extra software from this list.

  3. Export image to TMM GCP project tmm-instruqt-11-26-2021.

  4. Sanity check the image by logging into it. Provision a VM from the image in GCP.

    1. Launch the image with the following command to enable nested virtualization.
    gcloud compute instances create stratis-test --enable-nested-virtualization --image=projects/tmm-instruqt-11-26-2021/global/images/virt-rhel-9-2-10-11-23-2 --boot-disk-size=80GB --machine-type=n1-standard-4
    1. Check that the Instruqt SSH public key is added to /root/.ssh/authorized_hosts
    2. Ensure that the following VM qcow2 files are available in /var/lib/libvirt/images
      • composer-api-ee3492f7-5d95-4c1b-a223-bbf04b9adef4-disk.qcow2
      • vm1
      • rhel07
      • centos
      • converted
      • rhel08
      • rhel09
      • upgraded08
      • upgraded09
    3. Check that these qcow2 VMs have been imported into the virtual machines application in Web Console. If not, import them. Make sure each VM is using an e1000 NIC.
    4. Set the rhel user credentials to redhat.

    Virt image scripting

    Hosts file

    Virt images require a special set up script. The setup-<hostname> script must contain the following - virsh start <vm name> - We need to wait for the VM to boot and the NIC to come online. To figure out if the NIC is online, we'll run a one-line script that looks for the NIC based on its MAC address. As well, this script will append the IP address matching the specified MAC address to the VM name into the /etc/hosts file.

    while ! [ $( arp -an | grep 52:54:00:68:79:84 | awk '{print $2}' | tr -d '()' )  ]; do echo "Waiting for arp to return centos MAC address."; sleep 10; done;
    echo "$( arp -an | grep 52:54:00:68:79:84 | awk '{print $2}' | tr -d '()' ) centos" >> /etc/hosts

    Here's a list of the MAC addresses.

    # MAC Addresses
    # vm1:          52:54:00:d6:0c:72
    # centos:       52:54:00:68:79:84
    # converted:    52:54:00:87:d3:fc
    # rhel07:       52:54:00:02:ce:bb
    # rhel08:       52:54:00:43:26:d3
    # rhel09:       52:54:00:7f:e1:4e
    # upgraded08:   52:54:00:22:37:93
    # upgraded09:   52:54:00:e6:14:ee

    For more information, see this script

    Instruqt VM terminal

    The Instruqt VM terminal requires the terminal tab look like this:

    tabs:
    - title: centos
      type: terminal
      hostname: host
      cmd: ssh -o "StrictHostKeyChecking no" root@centos
    

    The cmd key-value pair creates a tab in Instruqt that creates an SSH session with the VM.

Software

See this page

Updates

Update the guest VMs before updating the host.

If VM fails to connect to the internet after the update, run the following.

nmcli dev con enp1s0