OpenStack's Image Service-Glance--A Deep Dive

Objective: Further to the previous post this is to install and configure the OpenStack's Image Service along with several concepts around it.

What is Glance?


The OpenStack's Image Service is known as Glance and provides the following services for Virtual Machine (VM) Images:-

- Discover
- Register
- Retrieve

This service provides REST API that enables us to query VM images metadata and retrieve an actual image.

This component is as highlighted in the screenshot below


from the above diagram we see that one of the services is glance-api which accepts calls for image discovery, retrieval and storage. The second one is glance-registry which stores, process and retrieves the  metadata like size, type and etc about the image. The third one is Database which stores image metadata, this could be any, but we would be choosing MySQL here.

Note: The storage repository for the Image service is the Object Storage Service, it could be as simple as the local filesystem to RADOS block devices or Amazon S3...

Using Glance you can even take snapshots of an image from an existing server for immediate storage. Use snapshots for backup and as templates to launch new servers.

Installing Glance


As mentioned, this a sequel to the previous post.

To install the Image service on the Controller node:

  1. yum install openstack-glance  

Now since we will be saving the metadata into the MySQL DB, set the variables the files /etc/glance/glance-api.conf and etc/glance/glance-registry.conf
sql_connection = mysql://glance:glance_password@controller/glance
We will now use the helper command openstack-db to create the image service database and tables in the mysql server along with creating a user called "glance" who will be using them.

  1. openstack-db --init --service glance --password glance_password  

Following this we will now let KeyStone let the identitiy management system know that there is a service called Glance and create a user with that name "glance", and assign it the role of an admin and add it to the "service" tenant.
  1. keystone user-create --name=glance --pass=glance_password --email=glance@example.com  
  2. keystone user-role-add --user=glance --tenant=service --role=admin  


Now we will edit these two files and set the variables as

  1. /etc/glance/glance-api.conf  
  2. /etc/glance/glance-registry.conf  

In /etc/glance/glance-api.conf under the section [keystone_authtoken]

auth_host = controller
admin_tenant_name = service
admin_user = glance
admin_password = glance_password

Under section paste_deploy
flavor = keystone

In the file /etc/glance/glance-registry.conf under the section [keystone_authtoken]
auth_host = controller
admin_tenant_name = service
admin_user = glance
admin_password = glance_password

Under section paste_deploy

flavor = keystone

Now adding the credentials to the /etc/glance/glance-api-paste.ini and /etc/glance/glance-registry-paste.ini, in Centos we copied the files to the correct location as well

  1. cp /usr/share/glance/glance-api-dist-paste.ini /etc/glance/glance-api- paste.ini  
  2. cp /usr/share/glance/glance-registry-dist-paste.ini /etc/glance/glance- registry-paste.ini  

and edit both the file to set the following options to the section [filter:authtoken]

paste.filter_factory=keystoneclient.middleware.auth_token:filter_factory
auth_host=controller
admin_user=glance
admin_tenant_name=service
admin_password=GLANCE_PASS
Now registering the Image service with the Identity service so that other openstack services can locate it.

To register the service and create the endpoint

  1. keystone service-create --name=glance --type=image --description="Glance Image service"  


Now using the ID property returned from the service to create the endpoint:

  1. keystone endpoint-create --service-id=e6.....seviceid --publicurl=http://controller:9292 --internalurl=http://controller:9292 --adminurl=http://controller:9292  



Now for the moment of truth starting the Glance service.

  1. service openstack-glance-api start  
  2. service openstack-glance-registry start  

And now ensuring that the service will start automatically when the system boots

  1. chkconfig openstack-glance-api on  
  2. chkconfig openstack-glance-registry on  

Taking the new glance for a spin


We can download an image, the lowest footprint one is the Cirros one.

  1. wget http://cdn.download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64- disk.img  


and now uploading this image to the Image service so that it can be used to create VMs with this OS installed.

  1. glance image-create --name="CirrOS 0.3.1" --disk-format=qcow2 \ --container-format=bare --is-public=true < cirros-0.3.1-x86_64-disk.img   


We are all set with Glance now. 

Popular posts from this blog

Ansible - Error - stderr: E: There are problems and -y was used without --force-yes

Error: SMTPIN_ADDED_BROKEN@mx.google.com