Using AMI Images in OpenStack

Image by lanomds / Unsplash

I recently had to validate some interactions between the OpenStack Image service, glance, and the Compute service, nova. For this, I needed separate kernel and ramdisk images. Glance supports a variety of image formats, which is required since different virtualization backends support different image formats. For quite some time, the DevStack installer defaulted to using AMI images, so if you’d run openstack image list on a fresh DevStack-based deployment, you’d have seen three CirrOS “images” with differing suffixes: -uec, -uec-ramdisk, and -uec-kernel. This has since changed, but there’s no reason we can’t create these types of image still.

First, let’s get the image. We’re going to want the Ubuntu Enterprise Cloud (UEC) CirrOS images:

$ wget https://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-uec.tar.gz

Extract this tarball, which will yield three files: a vmlinuz kernel image, a initrd ramdisk image, and a empty mkfs’d blank image:

$ tar -xvzf cirros-0.5.1-x86_64-uec.tar.gz

With those created, we can now create the three images in glance. First, the kernel image:

$ openstack image create cirros-0.5.1-x86_64-uec-kernel \
    --public --disk-format aki --container-format aki \
    --file cirros-0.5.1-x86_64-vmlinuz

Then the ramdisk image:

$ openstack image create cirros-0.5.1-x86_64-uec-ramdisk \
    --public --disk-format ari --container-format ari \
    --file cirros-0.5.1-x86_64-initrd

And finally the “machine” image, which requires references to the kernel and ramdisk image by way of image metadata properties:

$ openstack image create cirros-0.5.1-x86_64-uec \
    --property ramdisk_id=52ab2881-3f0e-4d0b-8824-d6c144eb872a \
    --property kernel_id=b582cf17-1785-4915-9b89-dc31c1794757 \
    --public --disk-format ami --container-format ami \
    --file cirros-0.5.1-x86_64-blank.img

Once done, you should be able to boot an instance using the machine image:

$ openstack server create cirros-server \
    --flavor m1.tiny --image cirros-0.5.1-x86_64-uec
comments powered by Disqus