How to create a ContainerDisk from a local image
Categories:
less than a minute
KubeVirt supports multiple ways of using images to create virtual machines. One of the most convenient methods is using the ContainerDisk feature, which allows VM disks to be stored and distributed as container images through a registry.
To create a ContainerDisk, users can simply inject the image into a container in qcow2 or raw format. The container should be based on scratch and the images must be placed into the /disk directory. No other content is required.
The following Dockerfile builds a ContainerDisk, which you can store in a OCI registry such as harbor or the Docker Hub:
FROM kubevirt/container-disk-v1alpha
ADD <your Image>.qcow2 /disk
You can the build the OCI arteiact with the command:
podman build . -t
Note: The ContainerDisk must be readable by the user with the UID 107 (qemu).
If you want to access the virtual machine, it is recommended to use a SSH key in the userdata startup section of your YAML file:
- name: cloudinitdisk
cloudInitNoCloud:
userData: |-
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaK8L93bWxnyp test@test.com