Example Virtual Machines¶
This guide walks through deploying an example Red Hat Enterprise Linux 9 virtual machine on OpenShift Virtualization. Use it as a smoke test after OpenShift Virtualization is installed, or as a starting point before failover and backup/restore exercises.
Prerequisites¶
- OpenShift Virtualization installed and the HyperConverged instance is healthy
- A default virtualization StorageClass (
storageclass.kubevirt.io/is-default-virt-class: "true") - Boot sources available in the cluster
ocand optionallyvirtctlinstalled locally
Verify boot sources before creating a VM:
Templates that show Source available in the console are ready to use. If RHEL sources are missing, wait for the DataImportCron jobs to finish or confirm the cluster can pull from the Red Hat registry.
Create a Project¶
Deploy from the Web Console¶
- Go to Virtualization → VirtualMachines → ensure you are in the
example-vmsproject → click Create → From template - Select Red Hat Enterprise Linux 9 (choose a tile with Source available)
- Name the VM
example-rhel9 - Click Customize VirtualMachine
Optional: Set Login Credentials¶
- Open the Scripts tab
-
Under Cloud-init, set a password for the guest user (or paste an SSH public key). Example cloud-init:
Note
RHEL cloud images do not ship with a usable default password. Set a password or SSH key before first boot, or you will not be able to log in from the console.
Optional: Confirm Disk and Run Strategy¶
- Open the Disks tab and confirm the root disk uses your virtualization StorageClass
- Prefer ReadWriteMany (RWX) if you plan to live-migrate or test failover later
- On the Overview tab, leave Start this VirtualMachine after creation selected so the VM boots immediately (
runStrategy: Always)
Create and Wait¶
- Click Create VirtualMachine
-
Wait until the VM status shows Running
Provisioning clones the boot source PVC first. On a cold cluster this can take several minutes.
Verify the Virtual Machine¶
From the CLI:
The VirtualMachine should be Ready, and the VirtualMachineInstance should show Running with a node assigned.
Check guest interfaces and IP (requires the QEMU guest agent, included on RHEL templates):
Watch creation events if the VM stays in provisioning:
oc get events -n example-vms --field-selector involvedObject.name=example-rhel9 --sort-by='.lastTimestamp'
Access the Console¶
- Go to Virtualization → VirtualMachines → click
example-rhel9 - Open the Console tab
- Log in as
cloud-userwith the password (or SSH key) you set in cloud-init -
Confirm the guest is healthy:
Deploy from the CLI (Optional)¶
You can create the same style of VM with virtctl using a cluster DataSource:
virtctl create vm \
--name example-rhel9 \
--instancetype u1.medium \
--preference rhel.9 \
--volume-import type:ds,src:openshift-virtualization-os-images/rhel9 \
--cloud-init-user cloud-user \
--cloud-init-password Pass123! \
| oc apply -n example-vms -f -
Start the VM if it was created stopped:
Watch until it is running:
Tip
Run virtctl create vm --help for additional options such as CPU/memory overrides, extra disks, and cloud-init SSH keys.
Cleanup¶
When deleting from the web console, confirm that associated disks (PVCs) are removed if you do not need to reuse them.
Next Steps¶
- VM Failover Test — validate node-loss recovery within the 120-second target
- VM Backup and Restore — exercise OADP with the kubevirt plugin
- Networking — attach VMs to a CUDN for persistent IPAM