Running Nova Openstack on Amazon EC2

The cloud has many practical uses for various applications, they range from the mundane. to the truly weird.

But have you ever wonder if you can run the “cloud” within the “cloud”, especially on Amazon EC2. Well now you can using Ubuntu Server, Openstack, and LXC as a base. Here is how..

First you need an Amazon EC2 instance. For our little project I suggest you use the latest Ubuntu Server release called “Natty Narwhal” on EC2 running an amd64 image (m1.large) . Get the largest instance you can because its easier to use in the long run, less headaches, and less hassles.

Once you instance has booted the first thing you have to do is to make sure your apt repositories are up to date and to enable cgroups. Cgroups is a linux kernel feature to limit, account, and isolate resource groups and processes. Cgroups is needed for libvirt to run LXC. So in order to enable cgroups in your EC2 instance all you have to do is the following:

sudo mkdir /cgroups

And modify your /etc/fstab accordingly

none /cgroups cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0

Just to be on the safe side reboot your EC2 instance. After you have rebooted its time to start installing Openstack on your instance. Since we are running a cloud on a single instance you need to do the following first:

sudo apt-get install rabbitmq-server dnsmasq

We are installing rabbitmq-server because its the AMQP provider that interacts with the different components of Nova. We are also installing dnsmasq because its basically your DHCP server for you cloud setup.

So next you have to install Nova. To do this on Ubuntu you have to do the following:

sudo apt-get install python-nova nova-common nova-api nova-compute nova-network nova-objectstore nova-scheduler nova-volume python-nova.adminclient unzip euca2ools

After you have installed the packages the next thing you have to do is configure Nova for LXC. To do this you need to modify the /etc/nova/nova.conf configuration file and add the following “–libvirt_type=lxc”. This will tell the nova-compute component to run libvirt to run with lxc. Then just to make life easier, reboot the instance again.

Once the instance has come backup the next step is configure your cloud, to do that you have to do the following:

sudo nova-manage network create 10.0.0.0/8 1 64
sudo nova-manage user admin
sudo nova-manage project create
mkdir me
cd me
sudo nova-manage project zipfile
source novarc

Once you have your cloud ready you need to run images on your cloud. Serge Hallyn has made some upstart scripts that are part of a the lxcguest package in Natty which makes it easier to run Ubuntu as a LXC container. Luckily, the UEC images found in “Natty Narwhal” have this package installed by default so the user doesn’t have to do any fiddling with their images to get it to work. To download the images you can point your favorite web browser here. Just remermber to download your images to your images to EC2.

Finally you need to upload the images to Nova’s objectstore. Its pretty easy to do:

tar -zxvf natty-server-uec-amd64.tar.gz
euca-bundle-image -i natty-server-uec-amd64.img
euca-upload-bundle -b -m /tmp/natty-server-uec-amd64.img.manifest.xml
euca-register-image /natty-server-uec-amd64.img.manifest.xm

Finally…you will  want to run the instance that you just uploaded to the objectstore:

euca-add-keypair mykey > mykey.priv
chmod 600 mykey.priv
euca-run-instances -k mykey -t m1.tiny

Using the “euca-describe-instances” command you should be able to see the instance running in a couple of minutes. Then finally should be able to ssh into the instance as the root user.

On a final thought is that I would like to the thank the Nova developers for making deploying a public/private cloud pretty easy and painless to do. If you have any feedback for me then you can contact me via email. Bug reports should be opened in Launchpad under the appropriate project. Enjoy your cloud with a cloud!

About these ads

March 31, 2011. Uncategorized.

Leave a Comment

Be the first to comment!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback URI

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: