I recently gave an introduction to the CloudFoundry Client application (vmc), which is already in Ubuntu 11.10's Universe archive.
Here, I'd like to introduce the far more interesting server piece -- how to run the CloudFoundry Server, on top of Ubuntu 11.10! As far as I'm aware, this is the most complete PaaS solution we've made available on top of Ubuntu Servers, to date.
A big thanks to the VMWare CloudFoundry Team who has been helping us along with the deployment instructions. Also, all of the packaging credit goes straight to Brian Thomason, Juan Negron, and Marc Cluet.
For testing purposes, I'm going to run this in Amazon's EC2 Cloud. I'll need a somewhat larger instance to handle all the services and dependencies (ie, Java) required by the platform. I find an m1.large seems to work pretty well, for $0.34/hour. I'm using the Oneiric (Ubuntu 11.10) AMI's listed at http://uec-images.ubuntu.com/oneiric/current/.
To install CloudFoundry Server, add the PPA, update, and install:
sudo apt-add-repository ppa:cloudfoundry/ppa sudo apt-get update
sudo apt-get install cloudfoundry-server
During the installation, there are a couple of debconf prompts, including:
- a mysql password
- required for configuration of the MySQL database (enter twice)
Next, install the client tools, either on your local system, or even on the server, so that we can test our server:
sudo apt-get install cloudfoundry-client
Now, you'll need to target your vmc client against your installed server, rather than CloudFoundry.com, as I demonstrated in my last post.
In production, you're going to need access to a wildcard based DNS server, either your own, or a DynDNS service. If you have a DynDNS.com standard account ($30/year), CloudFoundry actually supports dynamically adding DNS entries for your applications. We've added debconf hooks in the cloudfoundry-server Ubuntu packaging to set this up for you. So if you have a paid DynDNS account, just sudo dpkg-reconfigure cloudfoundry-server.
For this example, though, we're going to take the poor man's approach, and just edit our /etc/hosts file, BOTH locally on our laptop and on our CloudFoundry server.
First, look up your server's external IP address. If you're running Byobu in EC2, it'll be the lower right corner.
Otherwise, grab your IPv4 address from the metadata service.
$ wget -q -O- http://169.254.169.254/latest/meta-data/public-ipv4 188.8.131.52
And you'll need to add an entry to your /etc/hosts for api.vcap.me, AND every application name you deploy. Make sure you do this both on your laptop, and the server! Our test application here will be called testing123. Don't forget to change my IP address to yours ;-)
echo "184.108.40.206 api.vcap.me testing123.vcap.me" | sudo tee -a /etc/hosts
Now, let's target our vmc client at our vcap (CloudFoundry) server:
$ vmc target api.vcap.me Succesfully targeted to [http://api.vcap.me]
And add a user.
$ vmc add-user Email: email@example.com Password: ******** Verify Password: ******** Creating New User: OK Successfully logged into [http://api.vcap.me]
Now we can login.
$ vmc login Email: firstname.lastname@example.org Password: ******** Successfully logged into [http://api.vcap.me]
Deploying an Application
At this point, you can jump over to my last post in the vmc client tool for a more comprehensive set of examples. I'll just give one very simple one here, the Ruby/Sinatra helloworld + environment example.
Go to the examples directory, find an example, and push!
$ cd /usr/share/doc/ruby-vmc/examples/ruby/hello_env $ vmc push Would you like to deploy from the current directory? [Yn]: y Application Name: testing123 Application Deployed URL: 'testing123.vcap.me'? Detected a Sinatra Application, is this correct? [Yn]: y Memory Reservation [Default:128M] (64M, 128M, 256M, 512M, 1G or 2G) Creating Application: OK Would you like to bind any services to 'testing123'? [yN]: n Uploading Application: Checking for available resources: OK Packing application: OK Uploading (0K): OK Push Status: OK Staging Application: OK Starting Application: OKAgain, make absolutely sure that you edit your local /etc/hosts and add the testing123.vcap.me to the right IP address, and then just point a browser to http://testing123.vcap.me/
And there you have it! An application pushed, and running on your CloudFoundry Server -- Ubuntu's first packaged PaaS!
So the above setup is a package-based, all-in-one PaaS. That's perhaps useful for your first CloudFoundry Server, and your initial experimentation. But a production PaaS will probably involve multiple, decoupled servers, with clustered databases, highly available storage, and enterprise grade networking.
The Team is hard at work breaking CloudFoundry down to its fundamental components and creating a set of Ensemble formulas for deploying CloudFoundry itself as a scalable service. Look for more news on that front very soon!
In the meantime, try the packages at ppa:cloudfoundry/ppa (or even the daily builds at ppa:cloudfoundry/daily) and let us know what you think!