Setup a Simplestream Service

A Simplestream service allows Juju to retrieve information abut machine images used for starting new compute instances.

This necessary information is stored in a json metadata format called “simplestreams”. For supported public cloud services such as Amazon Web Services, HP Cloud, Azure, etc, no action is required by the end user. However, those setting up a private cloud, or who want to change how things work (eg use a different Ubuntu image), can create their own metadata.

This page explains how to use Juju and additional tools to generate this simplestreams metadata and configure OpenStack to use them.

We follow the instructions in Create a Simpestream service adapting them to the GARR cloud.

Install the Prerequisite Software

Install the Python clients:

$ sudo pip install python-openstackclient python-swiftclient

Install Juju:

$ sudo add-apt-repository -u ppa:juju/stable
$ sudo apt-get update
$ sudo apt install juju

Create a simplestream service

Create a new service in the Keystone service catalog for simplestreams:

$ openstack service create --name product-stream --description "Product Simple Stream" product-streams

We finally need to register an endpoint with the Simplestreams service. Enter the following commands:

$ openstack endpoint create --region $REGION product-streams public $SWIFT_PUB_URL/simplestreams/images/
$ openstack endpoint create --region $REGION product-streams internal $SWIFT_INTERNAL_URL/simplestreams/images/
$ openstack endpoint create --region $REGION product-streams admin $SWIFT_ADMIN_URL/simplestreams/images/

where $REGION is the cloud region name and $SWIFT_…URL are the Swift endpoint URLs retrieved in an earlier step.

For the GARR Cloud the values to use are:

REGION=garr-ct1
SWIFT_PUB_URL=http://90.147.165.90:80/swift/v1
SWIFT_INTERNAL_URL=http://10.3.4.238:80/swift/v1
SWIFT_ADMIN_URL=http://10.3.4.238:80/swift/v1

Generate the metadata

Create a directory to hold the generated metadata:

$ mkdir -p ~/simplestreams/images

Now source your OpenStack environment:

$ source my_os_env.rc

Determine the region name for the cloud by running:

$ openstack endpoint list

The relevant lines of the output are the public endpoints of the Swift and Keystone service:

ID Region Service Name Service Type Enabled Interface URL
3bd841742b8b43a39086dbe4282bb6e5 garr-ct1 keystone identity True public https://keystone.cloud.garr.it:5000/v3
901f24099e9049a0bc3b5b6a0ff43ddf garr-ct1 swift object-store True public http://90.147.165.90:80/swift/v1
11eb701210c34c5f80130c88c91ca194 garr-ct1 swift object-store True admin http://10.3.4.238:80/swift
5344f13f15fe460fb437ed4c369e6b55 garr-ct1 swift object-store True internal http://10.3.4.238:80/swift/v1

Take note of the URLs of the Keystone and Swift endpoints and of the Region name, which will be required in a later step.

Get the list of images available on the cloud:

$ openstack image list

The result should be something like this:

ID Name Status
   
2e0c162a-1762-4ab9-b5e8-96845296cd90 Ubuntu Xenial 16.04 amd64 active
8a84d788-f67d-45fe-98fa-37297d9979f1 Ubuntu Trusty 14.04 amd64 active

Take note of the image IDs which we will use in the next step.

We can now use Juju to generate the metadata:

$ juju metadata generate-image -d ~/simplestreams -i $IMAGE_ID -s $SERIES -r $REGION  -u $KEYSTONE_URL

substituting in the appropriate values:

  • $IMAGE_ID: the image ID we are creating metadata for.
  • $SERIES: the appropriate series this image relates to (e.g. Xenial).
  • $REGION: the region name of the cloud.
  • $KEYSTONE_URL: the address of the cloud’s Keystone server.

For the GARR Cloud, the values to use are:

REGION=garr-ct1
KEYSTONE_URL=https://keystone.cloud.garr.it:5000/v3

For instance, to generate the metadata of the Ubuntu 16.04 image the above command will translate to:

$ juju metadata generate-image -d ~/simplestreams -i 2e0c162a-1762-4ab9-b5e8-96845296cd90 -s xenial -r garr-ct1 -u https://keystone.cloud.garr.it:5000/v3

Adding others images is left as an exercise to the reader :)

N.B. The previous command has some issues in cas you have more OpenStack regions and a single Glance repository (like our GARR Cloud): repeating the command on the second region results in overwrinting the first one. This is because the json file identifies the image (“items” block) by its ID, which is the same in all regions:

cat cat images/streams/v1/com.ubuntu.cloud-released-imagemetadata.json
        "com.ubuntu.cloud:server:16.04:amd64": {
       "version": "16.04",
       "arch": "amd64",
       "versions": {
           "20181019": {
               "items": {
                   "9b34c74c-2e1a-4d67-84c6-72de689a6808": {
                       "id": "9b34c74c-2e1a-4d67-84c6-72de689a6808",
                       "region": "garr-pa1",
                       "endpoint": "https://keystone.cloud.garr.it:5000/v3"
                   },

The solution is manually replace the ID defining the item block with a unique number for each region, e.g:

 "items": {
"1": {
    "id": "9b34c74c-2e1a-4d67-84c6-72de689a6808",
    "region": "garr-pa1",
    "endpoint": "https://keystone.cloud.garr.it:5000/v3"
},
"2": {
    "id": "9b34c74c-2e1a-4d67-84c6-72de689a6808",
    "region": "garr-ct1",
    "endpoint": "https://keystone.cloud.garr.it:5000/v3"
}

To verify that the correct metadata files have been generated, you may run:

$ ls ~/simplestreams/*/streams/*

Upload the Simplestreams Metadata to Swift

Create a new container for the Simplestreams metadata:

$ openstack container create simplestreams

You can verify that the container has been created by running:

$ openstack container list

You can view the status of the container:

$ openstack container show simplestreams

Notice the Objects: line. You should see that the container does not contain any objects.

To upload the Simplestreams metadata to the container:

$ cd ~/simplestreams
$ swift upload simplestreams *

Check the status of the container:

$ swift stat simplestreams

Notice the Objects: line again. The container now should contain some objects. Since there are no Read or Write ACL, the container is private.

Add a Read ACL in order to make the container publicly accessible:

$ swift post simplestreams --read-acl .r:*

Bootstrap with Juju

Now that the simplestream service is registered and running you can create a controller on this cloud with the juju bootstrap command, following these instructions.