miércoles, 16 de junio de 2010

Getting dynamic on the cloud part #1

In order to be able to scale a voice service that runs on the cloud one must have the capacity to create and delete servers on demand. Amazon EC2 users have the capacity of specifiying a base image file or AMI. This is not the case on the Rackspace Cloud. It turns out that this is not a problem but an opportunity, as we can try Opscode Chef to dynamically configure (using a Ruby DSL) a node exactly as we want it.

When we create a server on Rackspace, we usually do not know what external or internal IP address we are going to get. Using the Right Rackspace tools from RightScale or the plain Rackspace API you can learn what IP address a server is going to have when it has finished creating, this is nice and all but then we need to store that IP address somewhere and if the server gets recreated it will most likely get a new IP address ( i have never had a rackspace cloud server fail on me ).

One way to work around this problem is to not rely on the IP address but to use DNS. Not plain boring DNS but dynamic DNS since we need to take into account that a server might get deleted and recreated (say at night when the server is not in use, to save some $$$).

In this article we want to be able to use right-rackspace and chef to create and provision rackspace cloud servers. You will need to get a Rackspace Cloud API key from their website

  
sudo gem install right_http_connection
sudo gem install right_rackspace



In the next part we are going to use BIND and nsupdate to perform the dns updates from the nodes to the DNS server, and we are going to use chef-solo to provision our servers. Chef Solo is a standalone version of chef that allows us to run chef recipes and cookbooks without having the whole chef infrastructure in place Now usually the reasons to use dynamic DNS is that we are on a Home or office DSL or cable-modem line that gets a public IP address from a provider. In the case of the cloud, once a server has an IP address it should never change, however since this is the cloud and everything is dynamic, we would like to pause the servers we are not using so that we do not pay for idle resources. Rackspace does not offer this, the next best thing is to delete and recreate the server on demand, which is fairly possible, but then we need to manage the ever-changing IP address.