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
sudo nova-manage project zipfile
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
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!
A feature for Natty that the Ubuntu Server team has been adding and improving is LXC container support. Linux containers is a light weight virtualization technology described by some as “chroots on steroids”.
In the past running LXC containers need a lot of hacks in the image due to various issues with upstart. But that has changed to the awesomeness of the lxcguest package. The lxcguest package will make running Ubuntu on LXC containers a trivial task. So running scripts to modify the images is now a thing of the past. Thanks Serge.
Also a new version of libvirt was uploaded to Natty recently. This version contains numerous fixes for LXC, previously in maverick if you ran container, the container would disappear once you connect to the console. Thankfully this is also fixed in more recent versions of libvirt, thanks to the upstream maintainers for libvirt. Also to Serge again for back porting the fix to Natty.
So you are probably where this is all leading to. Well now with the trunk version Open Stack you can run LXC enabled images as an EC2 or OpenStack API instance. This is a good thing for a couple of reasons, one reason is that it allows system administrators who doesn’t have the hardware to easily start deploying clouds in their data centers. However, for the high end system administrators LXC is a low overhead and fast deployment lots of instances in their Private Cloud. For developers of the openstack community it gives Nova developers who did not want to deploy either KVM or Xen a way to test their changes to the Nova code more easily.
Next we will look at how to deploy Nova with LXC.