Migrating Vmware VM to Kubevirt VM
Installing virtio drivers in ESX VM
Installing virtio drivers on Linux VM
Log into Linux VM and run the following command.
mkinitrd -f --allow-missing --with=virtio_scsi --preload=virtio_scsi --with=virtio_blk --preload=virtio_blk --with=virtio_pci --preload=virtio_pci --with=virtio_console --preload=virtio_console --with=virtio_net --preload=virtio_net --with=virtio --preload=virtio /boot/initramfs-$(uname -r).img $(uname -r)
Installing virtio drivers on Windows VM
Download the virtio-windows driver iso from location
Mount the iso as cdrom in ESX VM.
After booting the VM, goto cdrom —>NetKVM–> <Windows OS version> –>amd65. Right click on netkvm.inf file and select to install it.
For example in our case D:NetKVM2k19amd64
Similarly you can install scsi and block device drivers.
Note
Virtio for block device is not needed for booting but it gives much better performance than an emulated device. Block device virtio driver needs to be updated when same image is run in kubevirt environment. They dont work automatically. When you boot the same image in a kubevirt enviroment, as specified in yaml file virtio container disk will be loaded as cdrom. We may need to add a pvc say of 1G to the VM yaml file as another disk whose “bus” would be virtio instead of sata. So in device manager you would see that for that disk driver needs to be added which can be added from cdrom. Once driver is updated then in yaml file you can change the bus type from sata to virtio for boot disk also and restart the VM.
Convert VMDK images to QCOW2
Power off ESX VM, Copy vmdk files to the machine/node(Cluster nodes have qemu-img installed) where qemu-img is installed. Convert vmdk file to qcow2 image.
qemu-img convert -f vmdk -o qcow2 <vmdk-file.vmdk> <qcow2-image-name>Note
For each disk in a VM two vmdk files are generted. One file is actual disk image which has “flat” in its name and other vmdk file is metadata file about the flat file. We have to specify the metadata file in the command. For example following are two vmdk files for a disk in a VM kubevirt-win
kubevirt-win-flat.vmdk
kubevirt-win.vmdk
Command would be:
qemu-img convert -f vmdk -o qcow2 kubevirt-win.vmdk <qcow2-image-name>
Use QCOW2 image(s) for running Virtual Machines using kubevirt
Please refer to VMs on Kubernetes (kubevirt) on how to use kubevirt for creating and running Virtual Machines as containers.