How to create a containerDisk from a local image
Categories:
less than a minute
How to create a containerDisk from a local image
kubeVirt supports multiple ways of using Images to create virtual machines. One of the more convenient ways is using the containerDisk feature, which provides the ability to store and distribute VM disks as container images in 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 commands show a simple way to create a container, containing only a fedora image file.
cat << END > Dockerfile
FROM scratch
ADD --chown=107:107 fedora25.qcow2 /disk/
END
podman build -t vmidisks/fedora25:latest .
Note: The containerDisk needs to be readable for the user with the UID 107 (qemu).
if you want to access the virtaulo machine, it is recommended that you use a ssh key in the userdata startup section in your yaml file:
- name: cloudinitdisk
cloudInitNoCloud:
userData: |-
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaK8L93bWxnyp test@test.com