Using OBS to Create Custom Images for SUSE Virtualization
SUSE Virtualization is for running virtual machines, whether they are legacy applications, cloud-native workloads, or a combination of the two. To run a virtual machine, you need an image for it to boot from. Typically, these are either Linux operating system images or Windows images. In the case of Linux, many distros provide suitable “cloud images” in qcow2 format, with the cloud-init
tool pre-installed. This, in turn, enables SUSE Virtualization to perform automatic boot-time customisation of VMs, such as SSH key injection and package installation.
Why should you care about package installation? The default cloud images provided by the various Linux distros tend to be fairly minimal, and thus may not include dependencies required by SUSE Virtualization or your workloads. Consider the following examples:
qemu-guest-agent
: When installed, this package allows SUSE Virtualization to determine the IP address of the VM, to inject additional access credentials, and to freeze VM filesystems before taking snapshots and backups.iptables
: If you want to integrate SUSE Virtualization with Rancher, and have Rancher deploy RKE2 clusters on top of SUSE Virtualization—which is extremely neat, by the way—you’ll need to make sure this package is installed.
When you create a virtual machine, under “Advanced Options: Cloud Configuration”, there’s a chunk of YAML which defaults to the following:
#cloud-config package_update: true packages: - qemu-guest-agent runcmd: - - systemctl - enable - --now - qemu-guest-agent.service
The default YAML installs qemu-guest-agent
. If you need other packages for your specific workloads, you can add them to the packages
list here.
This method of package installation requires the following:
- The VM image needs to be preconfigured with access to the distro’s software repositories.
- Your VMs need internet access to be able to download packages.
Unfortunately, depending on the image and the environment, these requirements cannot always be met. Some images don’t come with software repositories preconfigured, or require a subscription activation to access them. Some deployment environments are air-gapped for security reasons, and thus don’t have direct internet access.
Wouldn’t it be nicer if all required packages were pre-installed in your image? This is where the openSUSE Build Service (OBS) comes in. SUSE already provides minimal VM cloud images for SUSE Linux Enterprise (SLE), and it’s possible to use OBS to create images derived from these with your required changes, including the installation of additional packages. We have documentation on how to do this, but I thought it might be helpful to show an example of an image I created based on SUSE Linux Enterprise Server (SLES) 15 SP7.
You can find the source for the image at isv:Rancher:Harvester:Images:SLE-15-SP7/kiwi-templates-Minimal. This is linked to SUSE:SLE-15-SP7:GA/kiwi-templates-Minimal, so we’re starting with the official SLES 15 SP7 minimal VM image. If you’re logged into your OBS account, you can click link diff on the Overview tab to see what I’ve changed.
--- Minimal.kiwi (revision 4) +++ Minimal.kiwi (revision 8) @@ -354,7 +354,9 @@ <package name="jeos-firstboot"/> <package name="fbiterm"/> <!-- Optionally used by jeos-firstboot for no n-latin fonts --> <package name="xfsprogs" /> - <package name="kernel-default-base"/> + <package name="kernel-default"/> + <package name="iptables"/> + <package name="qemu-guest-agent"/> </packages> <packages type="image" profiles="MS-HyperV"> <package name="hyper-v" arch="x86_64"/>
As you can see, I’ve added the iptables
and qemu-guest-agent
packages for reasons already mentioned above. I’ve also replaced kernel-default-base
with kernel-default
, which includes the iscsi_tcp
module that Longhorn requires.
This image is automatically published to https://download.opensuse.org/repositories/isv:/Rancher:/Harvester:/Images:/SLE-15-SP7/images/SLES15-SP7-Minimal-VM.x86_64.qcow2, so I can download it from that location for use in SUSE Virtualization. I performed the same steps previously to create SLE 15 SP4, SP5, and SP6 images with the same extra packages. You can find those images in sibling projects of the SP7 image on OBS.
If you’d like to try creating your own images, feel free to start with the ones above.
Related Articles
Sep 05th, 2023
Getting granular on GCC 12
Mar 13th, 2024
The Relationship Between Edge Computing and Cloud Computing
Mar 12th, 2025
SUSE Private Registry: A safe Harbor for your containers.
Sep 03rd, 2024