Skip to content

kubevirt/common-templates

kubevirt/common-templates

A set of (meta-)Templates to create KubeVirt VMs.

Overview

This repository provides VM templates in the form compatible with OpenShift templates and OpenShift Cluster Console Web UI and those can further be transformed into regular objects for use with plain Kubernetes.

The VM templates are generated from meta-templates via Ansible and libosinfo. The generated templates are parametrized according to three aspects: the guest OS, the workload type and the size. The generated content is stored in dist/.

The Ansible playbook generate-templates.yaml describes all combinations that should be generated.

Every template consists of a VirtualMachine definition which can be used to launch the guest, if a disk image is available (see below).

Requirements

Is it necessary to install the following components to be able to run the Ansible generator and the CI suite:

  • jq
  • ansible >= 2.4
  • libosinfo
  • python-gobject
  • osinfo-db-tools
  • intltool

Usage

By default the process below takes a generated template and converts it to an VM object that can be used to start a virtual machine.

# Clone the repository
$ git clone https://github.com/kubevirt/common-templates
$ cd common-templates

# Pull all submodules
$ git submodule init
$ git submodule update

# Build osinfo database
$ make -C osinfo-db

# Generate the template matrix
$ ansible-playbook generate-templates.yaml

# Pick a template by selecting
# - the guest OS - windows
# - the workload type - desktop
# - the size - medium

# Use the template
$ oc process --local -f dist/templates/windows10-desktop-medium.yaml

$ oc process --local -f dist/templates/windows10-desktop-medium.yaml  --parameters
NAME                    DESCRIPTION                       GENERATOR           VALUE
NAME                    VM name                           expression          windows-[a-z0-9]{6}
DATA_SOURCE_NAME        Name of the DataSource to clone                       win10
DATA_SOURCE_NAMESPACE   Namespace of the DataSource                           kubevirt-os-images

$ oc process --local -f dist/templates/windows10-desktop-medium.yaml | kubectl apply -f -
virtualmachine.kubevirt.io/windows10-rt1ap2 created

$

Templates

The table below lists the guest operating systems that are covered by the templates. The meta-templates are not directly consumable, please use the generator to prepare the properly parametrized templates first.

Note: The templates are tuned for a specific guest version, but is often usable with different versions as well, i.e. the Fedora 34 template is also usable with Fedora 35.

Guest OS Meta-template
Microsoft Windows Server 2012 R2 windows2k12
Microsoft Windows Server 2016 windows2k16
Microsoft Windows Server 2019 windows2k19
Microsoft Windows Server 2022 windows2k22
Microsoft Windows 10 windows10
Microsoft Windows 11 windows11
Fedora fedora
Red Hat Enterprise Linux 7 rhel7
Red Hat Enterprise Linux 8 rhel8
Red Hat Enterprise Linux 9 rhel9
Ubuntu ubuntu
openSUSE Leap opensuse
CentOS 7 centos7
CentOS Stream 8 centos-stream8
CentOS Stream 9 centos-stream9

License

common-templates are distributed under the Apache License, Version 2.0.