7.3. Enabling sparse image upload
When you use Red Hat Ceph Storage RADOS Block Device (RBD) as the storage back end for the Image service (glance), you can use sparse image upload to reduce network traffic and save storage space. This feature is useful in distributed compute node (DCN) environments. With a sparse image file, the Image service does not write null byte sequences. The Image service writes data with a given offset. Storage back ends interpret these offsets as null bytes that do not consume storage space.
Prerequisites
- Your Red Hat OpenStack Services on OpenShift (RHOSO) deployment uses Ceph Storage RBD as the storage back end for the Image service.
Procedure
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add the following parameters to theglancetemplate. Enable sparse image upload by setting therbd_thin_provisioningparameter toTrue:apiVersion: core.openstack.org/v1beta1 kind: OpenStackControlPlane spec: ... glance: template: databaseInstance: openstack databaseUser: glance customServiceConfig: | [DEFAULT] enabled_backends = <backend_name>:rbd enabled_import_methods=[web-download] [glance_store] default_backend = <backend_name> [<backend_name>] rbd_store_ceph_conf = /etc/ceph/ceph.conf store_description = "RBD backend" rbd_store_pool = images rbd_store_user = openstack rbd_thin_provisioning = True ...-
Replace
<backend_name>with the name of the default back end.
-
Replace
Update the control plane:
$ oc apply -f openstack_control_plane.yaml -n openstackWait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:$ oc get openstackcontrolplane -n openstackThe
OpenStackControlPlaneresources are created when the status is "Setup complete".提示Append the
-woption to the end of thegetcommand to track deployment progress.
Verification
You can import an image and check its size to verify sparse image upload.
Download the image file locally:
$ wget <file_location>/<file_name>-
Replace
<file_location>with the location of the file. Replace
<file_name>with the name of the file.For example:
$ wget https://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-1508.qcow2
-
Replace
Check the disk size and the virtual size of the image to be uploaded:
$ qemu-img info <file_name>For example:
$ qemu-img info CentOS-6-x86_64-GenericCloud-1508.qcow2 image: CentOS-6-x86_64-GenericCloud-1508.qcow2 file format: qcow2 virtual size: 8 GiB (8589934592 bytes) disk size: 1.09 GiB cluster_size: 65536 Format specific information: compat: 0.10 refcount bits: 1Import the image:
$ glance image-create-via-import --disk-format qcow2 --container-format bare --name centos_1 --file <file_name>- Record the image ID. It is required in a subsequent step.
Verify that the image is imported and in an active state:
Access the remote shell for the
OpenStackClientpod from your workstation:$ oc rsh -n openstack openstackclientView the image:
$ openstack image show <image_id>Exit the openstackclient pod:
$ exit
From a Ceph Storage node, verify that the size of the image is less than the virtual size from the output of step 2:
$ sudo rbd -p images diff <image_id> | awk '{ SUM += $2 } END { print SUM/1024/1024/1024 " GB" }' 1.03906 GB