Openstack installation : Image Service

Had followed steps given in https://docs.openstack.org – Content mostly from openstack.org – This is just a compilation on steps followed by me.  Minor changes may be observed as I had installed on Debian 9.6.

Previous Post : Install Identity Service
Next Post     : Install Compute Services on Controller Node

glance – Image service enables users to discover, register and retrieve virutal machine images using REST API.   The backend storage could be simple file system or could be object-storage systems like Openstack Object Storage.   For learning purpose, we will have the images stored in file system of controller node – by default this is /var/lib/glance/images folder on controller node.

Create a database, service credentials, and API endpoints for glance service

sandeep@controller:~$ mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '<password>';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '<password>';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]>

As openstack admin create glance user and ad the admin role to the glance user and service project

sandeep@controller:~$ . admin-openrc
sandeep@controller:~$ openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | f0daadb8f0814d4596820fc97c6d5040 |
| name                | glance                           |
| password_expires_at | None                             |
+---------------------+----------------------------------+
sandeep@controller:~$ openstack role add --project service --user glance admin
sandeep@controller:~$ openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | 3cc8c7b92e71451a9a3c8d6572455d68 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

Create glance service API end points

sandeep@controller:~$ openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 1c7f6f439f7b4979a46b22fed23b2602 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 3cc8c7b92e71451a9a3c8d6572455d68 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
sandeep@controller:~$ openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 2d1756d2eaed4550a2c5994ae963699d |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 3cc8c7b92e71451a9a3c8d6572455d68 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
sandeep@controller:~$ openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | cff5770941154d36a11cbea68af36cdd |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 3cc8c7b92e71451a9a3c8d6572455d68 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

Create glance service entity

sandeep@controller:~$ openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | ab6061a7df234f9a835a91c1d7cc8339 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

Install glance package

root@controller:/home/sandeep# apt install glance

Edit glance-api configuration /etc/glance/glance-api.conf with database connection, authentication endpoints and project details

In the [database] section, configure database access:

[database]
...
connection = mysql+pymysql://glance:<password>@controller/glance

In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access.  Remove any other configuration in [keystone_authtoken] section.

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = <password>


[paste_deploy]
...
flavor = keystone

In the glance_store section edit the local file system storage configuration

[glance_store]
...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

Update the glance_registry configuration /etc/glance/glance-registry.conf with db connection details, authentication enpoints and project details.

In the [database] section, configure database access:

connection = mysql+pymysql://glance:<password>@controller/glance

In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access:

[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = <password>

[paste_deploy]
...
flavor = keystone

Populate the glance database with required tables.

root@controller:/home/sandeep# su -s /bin/sh -c "glance-manage db_sync" glance
/usr/lib/python2.7/dist-packages/oslo_db/sqlalchemy/enginefacade.py:1171: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade
expire_on_commit=expire_on_commit, _conf=conf)
2018-12-02 04:48:10.802 18308 INFO migrate.versioning.api [-] 0 -> 1... 
2018-12-02 04:48:10.804 18308 INFO glance.db.sqlalchemy.migrate_repo.schema [-] creating table images
2018-12-02 04:48:10.985 18308 INFO migrate.versioning.api [-] done
...
...
2018-12-02 04:48:17.900 18308 INFO migrate.versioning.api [-] 43 -> 44... 
2018-12-02 04:48:17.921 18308 INFO migrate.versioning.api [-] done
root@controller:/home/sandeep#

Restart image services

root@controller:/home/sandeep# service glance-registry restart
root@controller:/home/sandeep# service glance-api restart

Verify glance service functionality.  Download cirros disk image

sandeep@controller:~$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
--2018-12-02 04:55:33-- http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)... 64.90.42.85, 2607:f298:6:a036::bd6:a72a
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12716032 (12M) [text/plain]
Saving to: ‘cirros-0.4.0-x86_64-disk.img’

cirros-0.4.0-x86_64-disk.img 100%[=====================================================================================================================>] 12.13M 1.12MB/s in 11s

2018-12-02 04:55:45 (1.06 MB/s) - ‘cirros-0.4.0-x86_64-disk.img’ saved [12716032/12716032]

sandeep@controller:~$

As admin user create disk image using openstack client

sandeep@controller:~$ . admin-openrc

sandeep@controller:~$ openstack image create "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                     |
| container_format | bare                                                 |
| created_at       | 2018-12-01T23:33:12Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/e7a99acf-f063-46c1-a376-e4f40861354c/file |
| id               | e7a99acf-f063-46c1-a376-e4f40861354c                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | a3e16bf71c96422eae74bc9f8c76c61b                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 12716032                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2018-12-01T23:33:13Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+

sandeep@controller:~$ openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| e7a99acf-f063-46c1-a376-e4f40861354c | cirros | active |
+--------------------------------------+--------+--------+
sandeep@controller:~$