Exporting Virtual Machine Images
This feature is used to export the system image of a virtual machine and upload it to object storage, allowing the files in object storage to be added as sources to the platform's virtual machine images.
TOC
ProcedureProcedure
Note: All operations below must be performed on the control node of the cluster where the virtual machine resides.
Stopping the Virtual Machine
-
Go to Administrator.
-
In the left navigation bar, click Virtualization Management > Virtual Machines.
-
Click on the name of the virtual machine whose system image needs to be exported, which will redirect you to the virtual machine details page in the Container Platform.
-
Click Stop.
Creating the vmexport Resource
-
Open the CLI tool.
-
Execute the following command to set variables.
Parameter explanation:
- NAMESPACE: The name of the namespace where the virtual machine resides; replace the <namespace> part with this name.
- VM_NAME: The name of the virtual machine whose system image needs to be exported; replace the <vm_name> part with this name.
- TTL_DURATION: The lifetime of the export task, defaulting to 2 hours but can be increased as needed.
-
Execute the following command to create the vmexport resource.
If similar echo information appears, it indicates successful creation.
-
Execute the following command to check the status of the vmexport resource.
Echo information:
-
When the PHASE field in the echo information changes to Ready, type ctrl (control) + c to stop the watch operation.
-
Execute the following command to get the TOKEN.
Downloading the Virtual Machine Image File
-
Execute the following command to get the IP address of the virtual machine export Pod in the specified namespace and store it in the EXPORT_SERVER_IP environment variable.
-
Execute the following command to set the URL environment variable, which points to the virtual machine's disk image file.
-
Execute the following command to download the image file, with the downloaded file named disk.img.gz.
Uploading the Virtual Machine Image File to Object Storage
Upload the downloaded image file to object storage. Any S3 tool can be used for the upload, and this document will introduce the mc (minio-client) tool as an example.
-
Execute the following command to configure the mc tool and connect to the specified S3 storage service.
Parameter explanation:
- ENDPOINT: The address of the S3 storage service; replace the
<ENDPOINT>part with this address. - ACCESSKEY, SECRETKEY: The user ak and sk of the S3 storage service used for authentication; for related information, please refer to MinIO Object Storage.
- ENDPOINT: The address of the S3 storage service; replace the
-
Execute the following command to create a bucket for storing the virtual machine image files.
-
Execute the following command to upload the exported virtual machine image file disk.img.gz to the created bucket.
Creating the Virtual Machine Image
-
Go to Administrator.
-
In the left navigation bar, click Virtualization Management > Virtual Machine Images.
-
Click Add Virtual Machine Image.
-
In the image address, fill in <ENDPOINT>/vmdisks/disk.img.gz, replacing the <ENDPOINT> part with the address of the S3 storage service. For other parameter explanations, please refer to Adding Virtual Machine Images.
-
Click Add.