Ubuntu Core (Snappy) on OpenStack / vSphere
For years a big gap existed between embedded OS for smartphone and server operating system. Mark Shuttleworth and his team have been working for quite some time on optimizing their Ubuntu operating system for the smartphone world. Beginning of december, they’ve announced a new transactionnally updated version of Ubuntu optimized for the cloud, the result of their years of working for the embedded world. Snappy is a minimal server image where applications can be upgraded and rolled back atomically. It’s not the only similar initiative, it started with CoreOS, a reachitected Linux OS to run modern infrastructure stacks, but RedHat is also trying to keep up with project Atomic. Snappy can be used to run Docker containers but not only, it’s one of the main differentiator of Canonical solution.
Unfortunately Canonical doesn’t offer a VMDK version of their Snappy technology, which we need to deploy it on our OpenStack vSphere environment. This article we’ll show you how to proceed then.
By its name, you can guess this part should be easy. It’s just a 113.4 MB download. You can get it below (update the version accordingly)
Don’t use the following one which contain some modification which prevent it to work on top of OpenStack :/
Convert image to VMDK
But to use it on OpenStack / VMware you need to convert it to a VMDK like this:
$ qemu-img convert -f qcow2 -O vmdk devel-core-amd64-disk1.img snappy.vmdk
Upload it to Glance
Its not Fun if we don’t have this innovative image available available in our own cloud.
Note: VMDK disks converted through qemu-img are always monolithic sparse VMDK disks with an IDE adapter type. Unfortunately this format isn’t bootable by the ESXi, so they will convert it the first time required.
You can now upload it with the following options:
$ glance image-create --name snappy --progress \ --is-public True \ --container-format bare --disk-format vmdk \ --property hypervisor_type="vmware" \ --property vmware_disktype="sparse" \ --property vmware_adaptertype="ide" < \ snappy.vmdk
If you try to deploy a
m1.tiny instance from this image, you’ll get a
No valid host was found error message and in the vSphere client
specified parameter was not correct. capacity error. It’s cause by the following bug. An easy workaround consist of updating the buggy image size with the correct size.
Check the real size of the sparse image with
$ head -20 snappy.vmdk # Disk DescriptorFile version=1 CID=549f59fb parentCID=ffffffff createType="monolithicSparse" # Extent description RW 20971520 SPARSE "snappy.vmdk" # The Disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.geometry.cylinders = "20805" ddb.geometry.heads = "16" ddb.geometry.sectors = "63" ddb.adapterType = "ide"
As you can see above you have 20971520 sector (of 512 bytes each), for a total of 10737418240 bytes. So lets now update the image size.
$ glance image-update --size 2361393152 <IMAGE_ID>
It’s now fixed !!!
Launch a Snappy instance
Deploying an image should be possible, if you select a flavor that fit the disk size obviously,
m1.tiny are too small. You need at least a
So launch such an instance using the previously uploaded
Snappy image. Type the following information in the Post-Creation Tab or you won’t be able to ssh to your instance
#cloud-config snappy: ssh_enabled: True
After a bit you’ll get a shiny brand new Snappy instance ready to play with.
Assign a floating IP to your instance and connect to it
If it doesn’t work, you maybe forgot to inject your SSH key. Too bad, start over or try to log in using the default
ubuntu/ubuntu login/password. If you’re lucky you’ll get a nice welcome message instead
Welcome to Ubuntu Vivid Vervet (development branch) (GNU/Linux 3.16.0-25-generic x86_64) * Documentation: https://help.ubuntu.com/ Welcome to the Ubuntu Core rolling development release. * See https://ubuntu.com/snappy It's a brave new world here in snappy Ubuntu Core! This machine does not use apt-get or deb packages. Please see 'snappy --help' for app installation and transactional updates. Last login: Sun Dec 28 02:42:41 2014 from 192.168.1.231 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.
Where do we start ? Lets ask for some info
$ snappy info release: ubuntu-core/devel frameworks: apps:
As you can see, it’s a devel release, the only one available right now. It’s a pristine Snappy, no frameworks or apps are installed yet. But what’s the difference between frameworks and apps ?
- frameworks extend the base system, they have custom security profiles
- apps are isolated from one another by default, they have limited permissions
Check your Snappy version
# snappy versions Part Tag Installed Available Fingerprint Active ubuntu-core edge 141 - 7f068cb4fa876c *
You can easily update your Snappy instance
# snappy update # snappy reboot # snappy versions
Note: commands prepended with # need to be run as root.
In case anything goes wrong, you can rollback to the previous version
# snappy rollback # snappy reboot # snappy versions
One of the main use case of such a barebone OS is to become a foundation for Docker. You can quickly install the required components. You can start by searching for it
$ snappy search docker
To install Docker
# snappy install docker
After few tens of seconds, you should get
Part Tag Installed Available Fingerprint Active docker edge 1.3.2.007 - b1f2f85e77adab *
This article isn’t about Docker, so I won’t go into any more details.
As of today, there isn’t many application ported to Snappy yet. But *owncloud is one of them, as we’ve seen with Docker, installation is a breeze
# snappy install owncloud
And hop you got a nice document repository in few minutes, check it’s installed
# snappy info release: ubuntu-core/devel frameworks: docker apps: owncloud
As you can see docker is a framework with priviledged access to the OS while owncloud is an app with restricted access.
But What about running an Ubuntu Trusty images within your OpenStack Cloud
You can use pretty much do the same process to convert and upload an Ubuntu Server image. For example :
$ wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img $ qemu-img convert -f qcow2 trusty-server-cloudimg-amd64-disk1.img \
-O vmdk trusty-server-cloudimg-amd64-disk1.vmdk
$ glance image-create --name trusty --progress --is-public True \ --container-format bare --disk-format vmdk \ --property hypervisor_type="vmware" \ --property vmware_disktype="sparse" \ --property vmware_adaptertype="ide" < \ trusty-server-cloudimg-amd64-disk1.vmdk
Check the real size of your image
$ head -20 trusty-server-cloudimg-amd64-disk1.vmdk # Disk DescriptorFile version=1 CID=549f583b parentCID=ffffffff createType="monolithicSparse" # Extent description RW 4612096 SPARSE "trusty-server-cloudimg-amd64-disk1.vmdk" # The Disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.geometry.cylinders = "4575" ddb.geometry.heads = "16" ddb.geometry.sectors = "63" ddb.adapterType = "ide"
As you can see about you have 4612096 sector (of 512 bytes each), for a total of 2361393152 bytes. So lets now update the image size.
$ glance image-update --size 2361393152 <IMAGE_ID>
You can now deploy new instances from this image.
How to check the adapter type of a VMDK image
All the VMDK you upload to Glance need to use the IDE adapter or it won’t work, before uploading one you can check the adapter type in the
ddb.adapterType property accessible like this
head -20 ubuntu-core-alpha-01.vmdk # Disk DescriptorFile version=1 CID=548829e8 parentCID=ffffffff createType="monolithicSparse" # Extent description RW 41943040 SPARSE "ubuntu-core-alpha-01.vmdk" # The Disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.geometry.cylinders = "41610" ddb.geometry.heads = "16" ddb.geometry.sectors = "63" ddb.adapterType = "ide"
If it’s not a IDE adapter you can force it when you upload it to glance by using the
--property vmware_adaptertype="ide" option.
How to convert a StreamOptimized image to a Sparse one
As far as I know StreamOptimized VMDK Images aren’t currently supported on Glance, so to convert them to sparse you can use a utils provided with VMware Fusion, just do:
/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager -r ./instance-disk1.vmdk -t 0 ./instance-sparse.vmdk