Bootable Volumes
A bootable volume is a ready-to-use boot image that virtual machines can be created from. Each bootable volume is a KubeVirt DataSource (cdi.kubevirt.io/v1beta1) backed by a PVC that CDI populates from an import or clone source. In the console, bootable volumes are managed as image instances — see Adding Image Instances, Managing Image Instances and Image Instances in a Namespace. This page describes them from the API side.
When you create a virtual machine and choose Provision Method > Image Instance, the picker lists the bootable volumes of the shared kube-public namespace — where platform "golden images" live — and of the virtual machine's own namespace.
TOC
NotesView bootable volumesAdd a bootable volumeDefault Instance Type and PreferenceCreate a virtual machine from a bootable volumeUpdate or delete a bootable volumeNotes
- A bootable volume is offered for virtual-machine creation only when its
DataSourcecarries thevirtualization.cpaas.io/*label contract below (at least the operating system and architecture, which the picker filters by), isReady, and — for a PVC source — its PVC is bound and its import succeeded. A data source without the labels still appears in the image instance list but is not offered in the Image Instance picker. - The console shows the import progress as the image instance status: Importing while CDI populates the backing PVC and Available once it can be used; see Status.
- Local Upload is not a source in the console; upload with
virtctlinstead (see Uploading a Local Image and Creating a Virtual Machine).
View bootable volumes
Bootable volumes are backed by DataSource objects in kube-public and in the namespaces that hold their own. List them directly:
Add a bootable volume
A bootable volume supports these sources; the console names them as listed:
Note: Create bootable volumes in your own namespace. The shared
kube-publicnamespace holds platform golden images published by a cluster administrator — users can consume (clone and boot from)kube-publicimages out of the box, but creating or modifying objects inkube-publicrequires elevated platform permissions.
Adding a bootable volume creates two objects: a DataVolume (CDI imports the image into a PVC) and a DataSource that points at it and carries the label contract. The example imports an image over HTTP; the console names the DataVolume <name>-img-<5 random characters> and makes the DataSource its owner, while a hand-written pair may share one name as below:
Choose the volume and access modes the storage class's StorageProfile offers; Block with ReadWriteMany is recommended where available (see Storage settings).
For the other source types, replace spec.source on the DataVolume with one of the following.
Registry:
S3, with a Secret holding accessKeyId and secretKey:
Clone an existing PVC:
Restore from a VolumeSnapshot:
Apply and watch the import:
Default Instance Type and Preference
A bootable volume can declare the instance type and preference that suit it, through labels on its DataSource:
When you create a virtual machine and select this bootable volume as the image instance, the declared instance type and preference are preselected in the Model area; you can still change them. The form also offers Follow the image, which writes the boot volume as the source of the reference; the platform reads the labels once, when the virtual machine is created (see Creating Virtual Machines). A namespaced instance type or preference can only be used by virtual machines in its own namespace.
CDI copies these labels onto the DataSource from the objects behind it — the PVC and the DataVolume of the same name, or the volume snapshot — and, when the DataVolume carries none of them, from the volume it was imported or cloned from. A label set only on the DataSource is therefore overwritten whenever one of those objects declares another value. In the console, use Update Default Specification on the image instance, which writes the choice on all of them (see Default specification). With kubectl, label the PVC and the DataVolume as well as the DataSource:
Or declare them in the DataSource (and the DataVolume) when you create it:
Changing the labels later affects virtual machines created afterwards; existing virtual machines keep the objects they were created with.
Create a virtual machine from a bootable volume
A virtual machine is created in its own namespace and clones its root disk from a bootable volume of kube-public or of that same namespace. Under the hood, the virtual machine references the data source in a dataVolumeTemplates entry — CDI clones the bootable volume into the new virtual machine's root disk:
The clone source namespace is restricted to the virtual machine's namespace and kube-public. Cloning from another non-public namespace may require additional CDI clone permissions.
Update or delete a bootable volume
In the console, use Re-import and Delete on the image instance; see Managing Image Instances. Deleting an image instance the console added removes its DataSource, and the import DataVolume, its PVC and its CA certificate ConfigMap follow through their owner references.
For a hand-written bootable volume, delete the DataSource and the DataVolume. The backing PVC is owned by the DataVolume (via ownerReferences), so it is garbage-collected automatically when the DataVolume is deleted — do not delete the PVC while the DataVolume still exists, or CDI will re-provision it:
If CDI already garbage-collected the DataVolume after a successful import, kubectl delete datavolume returns NotFound and the PVC is left without an owner — delete it directly in that case: