From the Canyon Edge -- :-Dustin

Monday, August 8, 2011

Howto: Install the CloudFoundry Server PaaS on Ubuntu 11.10



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/.

Installation

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)
All in all, the install took me less than 7 minutes!

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

Configuration

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
174.129.119.101

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 "174.129.119.101  api.vcap.me testing123.vcap.me" | sudo tee -a /etc/hosts

Target

Now, let's target our vmc client at our vcap (CloudFoundry) server:

$ vmc target api.vcap.me
Succesfully targeted to [http://api.vcap.me]

Adding Users

And add a user.

$ vmc add-user 
Email: kirkland@example.com
Password: ********
Verify Password: ********
Creating New User: OK
Successfully logged into [http://api.vcap.me]

Logging In

Now we can login.

$ vmc login 
Email: kirkland@example.com
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: OK

Again, 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!

What's Next?

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!

:-Dustin

7 comments:

  1. Are these packages suitable for lucid? We'd really like to use this but we prefer LTS releases.

    ReplyDelete
  2. Not sure what I'm doing wrong:

    using the UEC oneiric image with the ppa:


    apt-get install cloudfoundry-server
    [snap]
    bundle install successful for mongodb
    bundle install successful for postgresql
    /
    * Starting Cloud Foundry Server dea : RUNNING
    Setting up icedtea-netx (1.1.3-1ubuntu1) ...
    update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode.
    Setting up g++-4.6 (4.6.1-9ubuntu3) ...
    Setting up g++ (4:4.6.1-2ubuntu5) ...
    update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode.
    Setting up build-essential (11.5ubuntu1) ...
    Processing triggers for libc-bin ...
    ldconfig deferred processing now taking place
    Errors were encountered while processing:
    cloudfoundry-server
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    If I rerun apt-get install it finishes this time.

    Then when I try to use vmc from the same server:

    ubuntu@ppa6:~$ vmc target api.vcap.me
    Host is not valid: 'http://api.vcap.me'
    Would you like see the response [yN]? y
    HTTP exception: Errno::ECONNREFUSED:Connection refused - connect(2)

    I configured the "public ip" to be 127.0.0.1 and not to use a custom domain.

    ReplyDelete
    Replies
    1. I am also getting similar error. Is there a way to check from the processes on ubuntu if the server is running? Or how to restart the server?

      Delete
  3. Excuse me I'm completely new to this concept, and I need someone to please explain the following to me.

    when I edit my host file, and use external IP concurrently with api.vcap.me

    I get the following. Can someone explain to me why? Do I have to rout a port to my machine, and include that IP with a port number instad??

    administrator@UbuntuServer11-10:/opt/cloudfoundry-server/vcap$ vmc info
    Error (JSON 404): <!DOCTYPE HTML PUBLIC "-//IETF/...

    ReplyDelete
  4. Can the packages be updated to the latest and greatest VCAP thats in GIT?

    These packages are too old.

    And installing via the GIT setup scripts takes forever as it re-compiles lots of apps.

    ReplyDelete
  5. Hi,
    I want to change domain api.vcap.me to mydomain ( example: test.mydomain.com)
    How ?

    ReplyDelete

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin

Printfriendly