Chapter 6. Customizing the Image service (glance) import workflow
You can configure the Image service (glance) import workflow to control image uploads and processing. Enable import methods like glance-direct, web-download, or copy-image, monitor staged images, and use plugins for metadata injection and format conversion.
Users can upload their own images to the Image service by using the default glance-direct or web-download import methods. If you have multiple Red Hat Ceph Storage back ends for the Image service, you can also enable the copy-image import method. You can monitor uploaded images in a staging area before they go active in a storage back end, and you can configure the import workflow to run plugins to make user images discoverable, for example, the Inject Image Metadata plugin for metadata or the Image Conversion plugin for image formats.
6.1. Prerequisites リンクのコピーリンクがクリップボードにコピーされました!
-
You have the
occommand line tool installed on your workstation. -
You are logged on to a workstation that has access to the RHOSO control plane as a user with
cluster-adminprivileges. -
To use Image service
glanceCLI commands, source thecloudrcfile with the command$ source ./cloudrcbefore using them. If thecloudrcfile does not exist, then you need to create it. For more information, see Creating thecloudrcfile.
6.2. Distributed image import リンクのコピーリンクがクリップボードにコピーされました!
Distributed image import works with the glance-direct image import method, and it is enabled by default in Red Hat OpenStack Services on OpenShift (RHOSO).
When using the glance-direct image import method, users can upload local images to the Image service (glance) without any requirement for a shared storage area where API worker nodes (or replicas) stage images. Instead, staging is distributed because individual API workers have their own local and unshared staging directory. The API worker that owns the image data is the same API worker that performs the image import.
When the image is created and staged, the Image service records the URL of the staging API worker in a database. With this URL, other API workers can proxy image import requests from clients to the worker that has the image data and can perform the import operation. This workflow allows API worker nodes to be isolated for High Availability (HA) and distributed geographically for a distributed compute node (DCN) environment.
6.3. URI allowlist and blocklist for web-download sources リンクのコピーリンクがクリップボードにコピーされました!
You can limit the sources of web-download image imports by specifying a URI allowlist and blocklist in the glance template in your OpenStackControlPlane custom resource (CR) file.
You can allow or block image source URIs at three levels:
- scheme (allowed_schemes, disallowed_schemes)
- host (allowed_hosts, disallowed_hosts)
- port (allowed_ports, disallowed_ports)
If you specify both an allowlist and a blocklist at any level, the allowlist is honored and the blocklist is ignored. For an example of a URI allowlist, see Configuring a URI allowlist for web-import sources.
6.3.1. Decision logic for URI validation リンクのコピーリンクがクリップボードにコピーされました!
The Image service applies the following decision logic to validate image source URIs:
The scheme is checked.
- Missing scheme: reject
- If there is an allowlist, and the scheme is not present in the allowlist: reject. Otherwise, skip C and continue on to 2.
- If there is a blocklist, and the scheme is present in the blocklist: reject.
The host name is checked.
- Missing host name: reject
- If there is an allowlist, and the host name is not present in the allowlist: reject. Otherwise, skip C and continue on to 3.
- If there is a blocklist, and the host name is present in the blocklist: reject.
If there is a port in the URI, the port is checked.
- If there is a allowlist, and the port is not present in the allowlist: reject. Otherwise, skip B and continue on to 4.
- If there is a blocklist, and the port is present in the blocklist: reject.
- The URI is accepted as valid.
If you allow a scheme, either by adding it to an allowlist or by not adding it to a blocklist, any URI that uses the default port for that scheme by not including a port is allowed. If the URI does include a port, the URI is validated according to the default decision logic.
6.3.2. Default settings for the URI allowlist and blocklist リンクのコピーリンクがクリップボードにコピーされました!
The following allowlist and blocklist values are the default settings for the web-download image import method in your Red Hat OpenStack Services on OpenShift (RHOSO) deployment.
- allowed_schemes - [http, https]
- disallowed_schemes - empty list
- allowed_hosts - empty list
- disallowed_hosts - empty list
- allowed_ports - [80, 443]
- disallowed_ports - empty list
If you use the default values, users can only access URIs by using the http or https scheme, and they can only specify ports 80 and 443. Users do not have to specify a port, but if they do, it must be either 80 or 443.
6.3.3. Configuring a URI allowlist for web-import sources リンクのコピーリンクがクリップボードにコピーされました!
You configure the sources of web-import image downloads by specifying URI allowlists and blocklists in the glance template in your OpenStackControlPlane custom resource (CR) file.
In this example, you are using an FTP server for image upload. The default port for FTP is 21.
Procedure
Open your
OpenStackControlPlanecustom resource CR file,openstack_control_plane.yaml, and add the following parameters to theglancetemplate:Example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Because
ftpis in the list forallowed_schemes, this URL to the image resource is allowed: ftp://example.org/some/resource. -
Because 21 is not in the list for
allowed_ports, this URL to the same image resource is rejected: ftp://example.org:21/some/resource.
-
Because
Update the control plane:
oc apply -f openstack_control_plane.yaml -n openstack
$ oc apply -f openstack_control_plane.yaml -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:oc get openstackcontrolplane -n openstack
$ oc get openstackcontrolplane -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow TipAppend the
-woption to the end of thegetcommand to track deployment progress.
6.4. Configuring the copy-image import method for images リンクのコピーリンクがクリップボードにコピーされました!
You can configure the Image service (glance) to copy existing images to multiple Red Hat Ceph Storage stores.
Procedure
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add the following parameters to thecustomServiceConfigin theglancetemplate:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the control plane:
oc apply -f openstack_control_plane.yaml -n openstack
$ oc apply -f openstack_control_plane.yaml -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:oc get openstackcontrolplane -n openstack
$ oc get openstackcontrolplane -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
OpenStackControlPlaneresources are created when the status is "Setup complete".TipAppend the
-woption to the end of thegetcommand to track deployment progress.
6.5. Enabling or rejecting virtual machine image disk formats リンクのコピーリンクがクリップボードにコピーされました!
You can configure the Image service (glance) to enable or reject disk formats. For example, you can enable only RAW and ISO disk formats or reject images in QCOW2 disk format.
Procedure
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add the following parameters to theglancetemplate:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<raw>and<iso>with the formats you want to enable from the following supported supported disk formats: none, ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, iso, ploop.
-
Replace
Update the control plane:
oc apply -f openstack_control_plane.yaml -n openstack
$ oc apply -f openstack_control_plane.yaml -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:oc get openstackcontrolplane -n openstack
$ oc get openstackcontrolplane -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
OpenStackControlPlaneresources are created when the status is "Setup complete".TipAppend the
-woption to the end of thegetcommand to track deployment progress.
6.6. Enabling plugins for the image import workflow リンクのコピーリンクがクリップボードにコピーされました!
You can enable plugins for the image import workflow by configuring the image_import_plugins option in the glance-image-import.conf file. The plugins do not run in parallel; they run in the order in which they appear in the image_import_plugins list.
Image conversion is enabled by default when you use Red Hat Ceph Storage as the back end for the Image service.
Procedure
Configure plugins in the
glance-image-import.conffile. In this example, you convert the images to RAW format before you inject metadata properties.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.6.1. Injecting metadata to control instance placement リンクのコピーリンクがクリップボードにコピーされました!
You can enable the Inject Image Metadata plugin to apply metadata properties to images that are imported by cloud users so that instances that are launched from the images are located on specific Compute nodes.
The Inject Image Metadata plugin contains two parameters:
-
ignore_user_rolesis a comma-separated list of Identity service (keystone) roles that the plugin will ignore. If the user making the image import call has any of these roles, the plugin will not inject any properties into the image. -
injectis a comma-separated list of properties and values that will be injected into the image record for the imported image.
Procedure
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add the following parameters to theglancetemplate:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Replace
<backend_name>with the name of the default back end. -
Replace
<admin>with the user roles you want the plugin to ignore. -
Replace
<property1>,<value1>,<property2>,<value2>, and so on with the properties and values that you want to inject to the image.
-
Replace
Update the control plane:
oc apply -f openstack_control_plane.yaml -n openstack
$ oc apply -f openstack_control_plane.yaml -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until RHOCP creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:oc get openstackcontrolplane -n openstack
$ oc get openstackcontrolplane -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
OpenStackControlPlaneresources are created when the status is "Setup complete".TipAppend the
-woption to the end of thegetcommand to track deployment progress.
6.7. Enabling Image service change notifications リンクのコピーリンクがクリップボードにコピーされました!
You can enable notifications in the Image service (glance) for various events that occur during the image lifecycle. These notifications provide telemetry data that you can use for the following:
- Auditing, troubleshooting, and monitoring operations
- Integrating with other services such as Ceilometer for metrics collection and processing
The Image service uses the RabbitMQ message broker software for notification delivery to a configured message queue. When you specify a RabbitMQ instance to use for notifications, the glance-operator automatically updates the oslo_notifications section in the 00-config.conf file. This update switches the notification driver from noop (no notifications) to messagingv2 (notifications).
To enable notifications in the Image service, you add the notificationsBusInstance parameter to the glance template in your OpenStackControlPlane custom resource (CR) file. You use this parameter to specify the RabbitMQ instance name to use for requesting a transport URL.
Procedure
Open your
OpenStackControlPlaneCR file,openstack_control_plane.yaml, and add thenotificationsBusInstanceparameter to theglancetemplate:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the control plane:
oc apply -f openstack_control_plane.yaml -n openstack
$ oc apply -f openstack_control_plane.yaml -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until Red Hat OpenShift Container Platform (RHOCP) creates the resources related to the
OpenStackControlPlaneCR. Run the following command to check the status:oc get openstackcontrolplane -n openstack
$ oc get openstackcontrolplane -n openstackCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
OpenStackControlPlaneresources are created when the status is "Setup complete".TipAppend the
-woption to the end of thegetcommand to track deployment progress.Optional: Check the
00-config.conffile to verify the notification settings have been updated:Example:
oc rsh -c glance-httpd <glance-default-external-api-0> grep "oslo_messaging_notifications" /etc/glance/glance.conf.d/00-config.conf -A 2
$ oc rsh -c glance-httpd <glance-default-external-api-0> grep "oslo_messaging_notifications" /etc/glance/glance.conf.d/00-config.conf -A 2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
<glance-default-external-api-0>with the pod name.Example output:
[oslo_messaging_notifications] driver=messagingv2 transport_url = rabbit://<user>:<pwd>@rabbitmq.openstack.svc:5671/?ssl=1
[oslo_messaging_notifications] driver=messagingv2 transport_url = rabbit://<user>:<pwd>@rabbitmq.openstack.svc:5671/?ssl=1Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can turn off notifications by removing the
notificationsBusInstanceparameter from theglancetemplate and updating the control plane.
6.8. Creating the cloudrc file リンクのコピーリンクがクリップボードにコピーされました!
The Image service (glance) uses both openstack and glance client commands, within the openstackclient pod. When glance client commands are required, then the cloudrc file must be created on the openstackclient pod to enable their usage. Once created, the cloudrc file persists for the lifetime of the openstackclient pod.
Procedure
If the
cloudrcdoes not exist, for instance it cannot be sourced, then use the following command to create it:Copy to Clipboard Copied! Toggle word wrap Toggle overflow