You can reduce the time it takes to create virtual machines (VMs) in
VM Runtime on GDC by manually converting existing virtual disk
images to the qcow2 format. After you
convert an image, you can create and run VMs directly from it.
VM Runtime on GDC automatically converts non-qcow2 disk images
during deployment. However, if you create multiple VMs from the same
non-qcow2 image, VM Runtime on GDC converts the image every time,
which increases the time it takes to create and start each VM. Converting the
image first, as shown in this document, avoids this repeated conversion.
Before you begin
To create a VM after you convert your existing virtual disk image, you need access to the following resources:
- Access to Google Distributed Cloud version 1.12.0 (
anthosBareMetalVersion: 1.12.0) or higher cluster. You can use any cluster type capable of running workloads. If needed, try Google Distributed Cloud on Compute Engine or see the cluster creation overview. - The
virtctlclient tool installed as a plugin forkubectl. If needed, install the virtctl client tool.
Convert a virtual disk image
In this document, you use the
QEMU disk image utility
to convert existing virtual disk images to the qcow2 format. The qemu-img
tool can convert virtual disk images from multiple formats, such as vmdk or
vhdx, to the qcow2 format for use with VM Runtime on GDC.
To convert virtual disk images to the qcow2 format, complete the following
steps:
Install the
qemu-utilspackage using your Linux distro's package manager.Ubuntu
apt-get install qemu-utilsRHEL
yum install qemu-utilsUse
qemu-imgto convert the existing virtual disk image:qemu-img convert -f EXISTING_DISK_IMAGE_FORMAT -O qcow2 \ EXISTING_DISK_IMAGE_NAME \ CONVERTED_DISK_IMAGE_NAME.qcow2Replace the following values:
EXISTING_DISK_IMAGE_FORMAT: the format of your existing virtual disk image, such asvmdk.EXISTING_DISK_IMAGE_NAME: the path and name of your existing virtual disk image.CONVERTED_DISK_IMAGE_NAME: the path and name for your convertedqcow2virtual disk image.
For more information on the
qemu-imgtool, such as the different image format options, see the QEMU disk image utility documentation.
Create a VM with your converted image
If you want to see your converted virtual disk image in action, create a VM and
use the local qcow2-formatted image created in the previous section. For
production use, you should upload your converted virtual disk image to a central
repository and then
create a VM boot disk from HTTP source
or
from Cloud Storage using a Secret.
To use your local converted virtual disk image, complete the following steps:
Create a VM in your cluster:
kubectl virt create vm VM_NAME \ --os-type OS_TYPE \ --image CONVERTED_DISK_IMAGE_NAME.qcow2This command creates a VM with the defaults of 2 CPU, 4 Gi memory.
Replace the following values:
VM_NAME: name for your VMOS_TYPE: the OS type of your converted virtual disk image. Can belinuxorwindows.CONVERTED_DISK_IMAGE_NAME: the path and name of your convertedqcow2virtual disk image from the previous section.
It can take 10-20 minutes to create the VM from your locally converted virtual disk image, depending on the size of your image. Check the status of the VM with the
kubectlcommand:kubectl get gvm VM_NAMEReplace
VM_NAMEwith the name of your VM.The following example output shows the VM in a
Runningstate when the process is complete:NAME STATUS AGE IP MY_VM Running 64s 192.168.2.124
What's next
You can upload your converted virtual disk image in qcow2 format to an HTTP
source or Cloud Storage. The following documents show you how to then create a
VM from those sources: