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

  1. Open your OpenStackControlPlane CR file, openstack_control_plane.yaml, and add the following parameters to the glance template. Enable sparse image upload by setting the rbd_thin_provisioning parameter to True:

    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.
  2. Update the control plane:

    $ oc apply -f openstack_control_plane.yaml -n openstack
  3. Wait until RHOCP creates the resources related to the OpenStackControlPlane CR. Run the following command to check the status:

    $ oc get openstackcontrolplane -n openstack

    The OpenStackControlPlane resources are created when the status is "Setup complete".

    提示

    Append the -w option to the end of the get command to track deployment progress.

Verification

You can import an image and check its size to verify sparse image upload.

  1. 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
  2. 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: 1
  3. Import the image:

    $ glance image-create-via-import --disk-format qcow2 --container-format bare --name centos_1 --file <file_name>
  4. Record the image ID. It is required in a subsequent step.
  5. Verify that the image is imported and in an active state:

    • Access the remote shell for the OpenStackClient pod from your workstation:

      $ oc rsh -n openstack openstackclient
    • View the image:

      $ openstack image show <image_id>
    • Exit the openstackclient pod:

      $ exit
  6. 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
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部