www.awcloud.com 解云惑 · 简为道
and cons, and usage scenarios Jia Zeng zengjia@awcloud.com Dongcan - - PowerPoint PPT Presentation
and cons, and usage scenarios Jia Zeng zengjia@awcloud.com Dongcan - - PowerPoint PPT Presentation
Several ways to create a virtual machine image, pros and cons, and usage scenarios Jia Zeng zengjia@awcloud.com Dongcan Ye yedongcan@awcloud.com www.awcloud.com 01 Background 02 Methods of creating instance
CONTENTS
Background
02
Methods of creating instance image
03
Pros and Cons
04
Operation demonstration
01 05
Usage scenarios Discussion
06
www.awcloud.com 解云惑 · 简为道
Background
In OpenStack, Glance service provide OS images for instance. Some users wants to save instance(running or not) as images. From end-user doubt :
- 1. How to create images based
- n instance?
- 2. Which way is better?
- 3. How to use those methods
for different scenarios? Create images based
- n instance
slow take space ......
www.awcloud.com 解云惑 · 简为道
Methods for instance to create images
From Nova side: # nova image-create <server> <name> From Cinder side: # cinder upload-to-image <volume> <image-name> There are two methods for instance to create image:
www.awcloud.com 解云惑 · 简为道
Methods for instance to create images
- 1. Call Nova API createImage
- 2. Determine instance is
volume backend or not
- 3. If volume backend instance,
call Cinder snapshot interface
- 4. Otherwise call Nova libvirt
driver to live snapshot or cold snapshot
Nova createImage API is_volume_bac kend_instance call Nova snapshot call Cinder snapshot
NO YES
snapshot upload to Glance,create mapping info create snapshot mapping update Glance DB
www.awcloud.com 解云惑 · 简为道
Methods for instance to create images
(1) non-volume backend instance
- An instance’s root disk copy,
then upload to Glance.
- cold/live snapshot
- direct_snapshot for RBD, if
direct_snapshot not support or failed, do standard snapshot.
- direct_snapshot
- snapshot the root disk and
clone it into Ceph Glance's pool
- flatten the osd image
- after all done with the
source snapshot, clean it up
- makes a protected snapshot
called 'snap' on uploaded images
snapshot suspend instance check requirement for live snapshot No blockJobAbort create snapshot Yes Create snapshot resume instance Thaw filesystems Freeze filesystems
www.awcloud.com 解云惑 · 简为道
Methods for instance to create images
(2) volume backend instance
- Freeze the guest filesystems(QGA supported)
- Call Cinder API to create snapshot
- Thaw the guest filesystems
- Update Glance image meta and snapshot
mapping This is the most common scenario snapshot_volume_backed Quiesce instance Cinder create_snapshot_force Unquiesce instance Update Glance image meta and snapshot mapping
www.awcloud.com 解云惑 · 简为道
Methods for instance to create images
- 2. From Cinder side
Upload volume to Glance, we can specify disk-format for the new image:
- qcow2: upload quickly and take less
space
- raw: upload slowly and take more
space copy_volume_to_image:
- _attach_volume
- RBD: rbd export
Cinder volume_upload_image API call Glance create image info copy_volume_to_image get volume info, convert to qcow2 upload volume to Glance, update image info disk- format is RAW? not convert No Yes
www.awcloud.com 解云惑 · 简为道
Pros and Cons
Interface description Pros Cons nova image-create Create snapshot for root disk, upload to Glance image
- upload fast
- Freeze the guest
filesystems, can make data consistency The new image may relay on the root disk and snapshot cinder upload-to- image --disk qcow2 Convert the disk to qcow2, then upload to Glance image
- upload fast
- take up less space
- has no relationship
with original root disk
- Cinder will not
freeze the disk cinder upload-to- image
- -disk raw
Directly upload the disk to Glance image
- After convert to raw
image, create instance will be faster
- upload slow
- take up more
space
- Cinder will not
freeze the disk
www.awcloud.com 解云惑 · 简为道
Usage scenarios
- 1. Nova image-create
- For the instance boot from image, we can produce image for the instance, this is
uncommon case.
- For the instance boot from volume, if user wants to produce image quickly, and finally no
need to delete root disk and snapshot, this is common case.
www.awcloud.com 解云惑 · 简为道
Usage scenarios
- 2. Cinder upload-to-image
- Upload disk(root disk) to Glance with qcow format, this is common case. We can delete the
- riginal disk, and uploads quickly.
- Upload disk(root disk) to Glance with raw format, this is also common case. If user has no
requirement for the speed, we can use this way. As we know, create instance with the raw image will quicker than others.(For RBD driver)
www.awcloud.com 解云惑 · 简为道
Operation demonstration
Create volume backend VM: # nova boot volume-vm --flavor 4d360a12-991a-4e08-bd1b-3bab987353bd --nic net- id=e44c3bac-6fea-4b04-8680-30e60d2e4aa1 --block-device id=f0a7da4d-2c70-47eb-a67a- 71a04d6678de,source=image,dest=volume,size=100,bootindex=0 Create local VM: # nova boot local-vm --flavor 4d360a12-991a-4e08-bd1b-3bab987353bd --nic net- id=e44c3bac-6fea-4b04-8680-30e60d2e4aa1 --block-device id=f0a7da4d-2c70-47eb-a67a- 71a04d6678de,source=image,dest=local,size=20,bootindex=0 Nova side create image: # nova image-create SERVER IMAGE-NAME Cinder side create image: # cinder upload-to-image --force True --disk-format raw VOLUME-ID IMAGE-NAME # cinder upload-to-image --force True --disk-format qcow2 VOLUME-ID IMAGE-NAME
www.awcloud.com 解云惑 · 简为道
Discussion
Optimization for Cinder upload-to-image
- 1. https://blueprints.launchpad.net/cinder/+spec/optimze-rbd-copy-volume-to-image
Not implemented yet, for the RBD driver. Cinder and Glance both has Ceph RBD backend, use volume copy function instead of rbd export.
- 2. https://review.opendev.org/#/c/668943
While uploading volume to Glance, if disk-format is qcow2, compress images with command ”qemu-img convert –c”
- 3. https://review.opendev.org/#/c/668825/
Leverage hardware accelerator to do the image compression. The only accelerator supported in Train release is Intel QuickAssist Technology (QAT)
解云惑 · 简为道 www.awcloud.com