Run your own Ubuntu Enterprise Cloud, part 2
Disclaimer: I’m now working on the OpenStack project, which provides the same kind of functionality as Eucalyptus.
Important update: This howto was targeted at 9.10. The 10.04 release of UEC introduces plenty of simplification (autoregistration of components, uec-publish-tarball automatically registering cloud images…) that makes some of this guide obsolete. Please see https://help.ubuntu.com/community/UEC/ which is kept much more up to date. As an alternative, see http://testcases.qa.ubuntu.com/Install/ServerUECTopology1, which details the testcase we run to validate UEC internally.
In part 1 of this series, we saw how to install the cloud infrastructure. In this article, we’ll bundle and upload an EMI (Eucalyptus Machine Image), based on Ubuntu Server 9.10 Beta, and validate that we can run an instance of it.
Download required elements
Go to the cloud/cluster controller and download the required items.
For a 64-bit image:
$ URL="http://uec-images.ubuntu.com/releases/karmic" $ wget -O image.gz $URL/beta/ubuntu-uec-karmic-amd64.img.gz $ wget -O vmlinuz $URL/beta/ubuntu-uec-karmic-amd64-vmlinuz-2.6.31-11-server $ wget -O initrd $URL/beta/ubuntu-uec-karmic-amd64-initrd.img-2.6.31-11-server
For a 32-bit image:
$ URL="http://uec-images.ubuntu.com/releases/karmic" $ wget -O image.gz $URL/beta/ubuntu-uec-karmic-i386.img.gz $ wget -O vmlinuz $URL/beta/ubuntu-uec-karmic-i386-vmlinuz-2.6.31-11-generic-pae $ wget -O initrd $URL/beta/ubuntu-uec-karmic-i386-initrd.img-2.6.31-11-generic-pae
Bundle the EMI
First you should unpack and resize your image to the desired size, lets say 4Gb. This can take a very long time (15 minutes !) on slow disks as you unpack 10Gb-worth of image space:
$ zcat -f image.gz | cp --sparse=always /dev/stdin image $ e2fsck -f image $ resize2fs image 4G $ truncate --size=4G image
Then bundle and upload the kernel:
$ . eucarc $ euca-bundle-image -i vmlinuz --kernel true $ euca-upload-bundle -b ueckernel -m /tmp/vmlinuz.manifest.xml $ euca-register ueckernel/vmlinuz.manifest.xml IMAGE eki-KKKKKKKK
Take note of the EKI reference, you’ll need it later. Then bundle, upload and register the ramdisk:
$ euca-bundle-image -i initrd --ramdisk true $ euca-upload-bundle -b uecramdisk -m /tmp/initrd.manifest.xml $ euca-register uecramdisk/initrd.manifest.xml IMAGE eri-RRRRRRRR
Take note of the ERI reference. Finally, bundle the image with the kernel and ramdisk, upload and register:
$ euca-bundle-image -i image --kernel eki-KKKKKKKK --ramdisk eri-RRRRRRRR $ euca-upload-bundle -b uecimage -m /tmp/image.manifest.xml $ euca-register uecimage/image.manifest.xml IMAGE emi-XXXXXXXX
Bundling will also take a lot of time ! Take note of your EMI reference.
Start an instance of your EMI
In order to access your instance using SSH, you’ll need to setup a few one-time things (create a SSH key and authorize access to port 22 of your instances):
$ euca-add-keypair mykey > mykey.priv $ chmod 0600 mykey.priv $ euca-authorize default -P tcp -p 22 -s 0.0.0.0/0
Now it’s time to start your instance !
$ euca-run-instances -k mykey emi-XXXXXXXX -t c1.medium
The “c1.medium” VM type is sufficient by default to run a 4Gb instance. You should take note of the i-YYYYYYYY reference that is displayed on your INSTANCE line. The first time you start an EMI, it can take some time (like 10 minutes) to move from “pending” state to “running”, depending on size. You can use the following command to automatically watch the output of euca-describe-instances, every 5 seconds:
$ watch -n 5 euca-describe-instances
Take note of the first ZZZ.ZZZ.ZZZ.ZZZ IP address mentioned in the output of the command. When the instance is “running”, ctrl-C to exit watch, then:
$ ssh -i mykey.priv ubuntu@ZZZ.ZZZ.ZZZ.ZZZ
You are in ! When you’re done playing with your instance, just run the following command on the cloud/cluster controller.
$ euca-terminate-instances i-YYYYYYYY
In the third and last part of this series of articles, we’ll talk about how to run instances from another workstation, as a cloud “customer”.