From the Canyon Edge -- :-Dustin
Showing posts with label VMWare. Show all posts
Showing posts with label VMWare. Show all posts

Sunday, March 18, 2012

Patchwork of Open Source Memories


One of the biggest differences in my new job is that I have to commute into the office every day.  And with that, comes the second biggest difference -- that I can't wear a t-shirt and pajama pants as I sit and hack the day away in my Eames lounger.

And so I drive 12 (scenic) miles from my house in the hills west of Austin right to the heart of downtown, fighting traffic if I sleep even a few minutes past 7:15am.  I wear a button-up shirt almost every day.  Not that that's formal -- I also wear jeans and cowboy boots.  But I'm dressing for the job I want, not the job I have.  A dude rancher, I reckon  :-)

The net result is that I had a closet full of awesome Linux and open source t-shirts -- shirts I had worn for years -- that just weren't getting their due anymore.  And my Etsy-awesome lovely wife Kim convinced me to part with a number of my favorites to create a t-shirt quilt that captures my last ~7 years in the Open Source world!

Now, mind you, I shed a tear or two as Kim's shears tore through a couple of these shirts that I've carried with me across six continents and most of the two dozen timezones...  :-/  On the other hand, a few of these weren't particularly my favorites, but did fit the color scheme she was going for.  In the end, her work was really quite beautiful!  And warm.

For those interested, I'll document the 6 rows by 4 columns:


Ah memories...  So Kim enjoyed making this for me, but it was a heck of a lot of work, and I don't think she'll be doing it again.  But if you're looking for a quilt made of your own favorite shirt, check out our friend Liz who has her own Etsy site for this sort of thing ;-)

Cheers!
:-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

Monday, July 25, 2011

Getting started with the CloudFoundry Client in Ubuntu


I'm pleased to introduce a powerful new cloud computing tool available in Ubuntu 11.10 (Oneiric), thanks to the hard work of my team (Brian Thomason, Juan Negron, and Marc Cluet), as well as our partners at VMWare -- the cloudfoundry-client package, ruby-vmc and it's command line interface, vmc.

CloudFoundry is a PaaS (Platform as a Service) cloud solution, open sourced earlier this year by VMWare.  Canonical's Systems Integration Team has been hard at work for several weeks now packaging both the client and server pieces of CloudFoundry for Ubuntu 11.10 (Oneiric).  We're at a point now where we'd love to get some feedback from early adopting Oneiric users on the client piece.

PaaS is a somewhat new area of Cloud Computing for Ubuntu.  Most of our efforts up to this point have been focused on IaaS (Infrastructure as a Service) solutions, such as Eucalyptus and OpenStack.  With IaaS, you (the end user of the service) run virtual machine instances of an OS (hopefully Ubuntu!), and build your solutions on top of that infrastructure layer.  With PaaS, you (the end user of the service) develop applications against a given software platform (within a few constraints), but you never actually touch the OS layer (the infrastructure).

CloudFoundry is one of the more interesting open source PaaS offerings I've used lately, supporting several different platforms already (Ruby, NodeJS, Spring Java), and several backend databases (MySQL, MongoDB, Redis), and support for other languages/databases under rapid development.

VMWare is hosting a free, public CloudFoundry server at cloudfoundry.com (though you need to request an invite; took mine less than 48 hours to be arrive).  However, we're rapidly converging on a cloudfoundry-server package in a PPA, as well as an Ensemble formula.  Stay tuned for a subsequent introduction on that, and a similar how-to in the next few days...

In the mean time, let's deploy a couple of basic apps to CloudFoundry.com!

Installing the Tools

The tool you need is vmc, which is provided by the ruby-vmc package.  We in the Canonical SI Team didn't find that package name very discoverable, so we created a meta package called cloudfoundry-client.

sudo apt-get install cloudfoundry-client

Setting the Target

First, you'll need to set the target server for the vmc command.  For this tutorial, we'll use VMWare's public server at cloudfoundry.com.  Very soon, you'll be able to target this at your locally deployed CloudFoundry server!

$ vmc target https://api.cloudfoundry.com
Succesfully targeted to [https://api.cloudfoundry.com]

Logging In

Next, you'll log in with your credentials.  As I said above, it might take a few hours to receive your credentials from CloudFoundry.com, but once you do, you'll log in like this:

$ vmc login
Email: kirkland@example.com
Password: **********
Successfully logged into [https://api.cloudfoundry.com]

Deploying Your First Applications

Your friendly Canonical Systems Integration Team have developed and tested a series of simple hello-world applications in each of CloudFoundry's supported languages.  Each of these applications simply print a welcome message, and display all of the environment variables available to the application.  The latter bit (the environment variables) are important, as several of them, those starting with VCAP_*, serve as a sort of metadata service for your applications.

Our sample apps are conveniently placed in /usr/share/doc/ruby-vmc/examples.

Deploying a Ruby Application

To deploy our sample Ruby application:

$ 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: example101
Application Deployed URL: 'example101.cloudfoundry.com'? 
Detected a Sinatra Application, is this correct? [Yn]: y
Memory Reservation [Default:128M] (64M, 128M, 256M, 512M or 1G) 128M
Creating Application: OK
Would you like to bind any services to 'example101'? [yN]: n
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (0K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK                                                        

And now, I can go to http://example101.cloudfoundry.com/ and see my application working.

Deploying a NodeJS Application

Next, I'm going to deploy our sample NodeJS application:

$ cd /usr/share/doc/ruby-vmc/examples/nodejs/hello_env
$ vmc push
Would you like to deploy from the current directory? [Yn]: y
Application Name: example102
Application Deployed URL: 'example102.cloudfoundry.com'? 
Detected a Node.js Application, is this correct? [Yn]: y
Memory Reservation [Default:64M] (64M, 128M, 256M, 512M or 1G) 64M
Creating Application: OK
Would you like to bind any services to 'example102'? [yN]: n
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (0K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK                                                       

And now, I can go to http://example102.cloudfoundry.com/ and see my simple NodeJS application running.

Deploying a Java Application

Now, we'll deploy our sample Java application.

$ cd /usr/share/doc/ruby-vmc/examples/springjava/hello_env

As with anything that involves Java, it's hardly as simple as our other examples :-) First we need to install the Java tool chain, and compile our jar file. I recommend you queue this one up and go brew yourself a gourmet pot of coffee. (You might even make it to Guatemala and back.) Also, note that we'll make a copy of this directory locally, because the maven build process needs to be able to write to the local directory.

$ sudo apt-get install openjdk-6-jdk maven2
...
$ cd $HOME
$ cp -r /usr/share/doc/ruby-vmc/examples/springjava .
$ cd springjava/hello_env/
$ mvn clean package
...
$ cd target
$ vmc push
Would you like to deploy from the current directory? [Yn]: y
Application Name: example103
Application Deployed URL: 'example103.cloudfoundry.com'?  
Detected a Java Web Application, is this correct? [Yn]: y
Memory Reservation [Default:512M] (64M, 128M, 256M, 512M or 1G) 512M
Creating Application: OK
Would you like to bind any services to 'example103'? [yN]: n
Uploading Application:
  Checking for available resources: OK
  Packing application: OK
  Uploading (4K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK

All that for a Java hello-world ;-) Anyway, I now have it up and running at http://example103.cloudfoundry.com/.

Deploying a More Advanced Application

Hopefully these hello-world style applications will help you get started quickly and effortlessly deploy your first CloudFoundry apps. But let's look at one more complicated example -- one that requires a database service!

In digging around the web for some interesting NodeJS applications, I came across the Node Knockout programming competition. I found a few interesting apps, but had a lot of trouble tracking down the source for some of them. In any case, I really liked a shared-whiteboard application called Drawbridge, and I did find its source in github. So I branched the code, imported it to bzr and made a number of changes (with some awesome help from my boss, Zaid Al Hamami). I guess that's an important point to make here -- I've had to do some fairly intense surgery on pretty much every application I've ported to run in CloudFoundry, so please do understand that you'll very likely need to modify your code to port it to the CloudFoundry PaaS.

In any case, let's deploy Drawbridge to CloudFoundry!

$ cd $HOME
$ bzr branch lp:~kirkland/+junk/drawbridge
$ cd drawbridge
$ vmc push
Would you like to deploy from the current directory? [Yn]: y
Application Name: example104
Application Deployed URL: 'example104.cloudfoundry.com'? 
Detected a Node.js Application, is this correct? [Yn]: y
Memory Reservation [Default:64M] (64M, 128M, 256M or 512M) 128M
Creating Application: OK
Would you like to bind any services to 'example104'? [yN]: y
Would you like to use an existing provisioned service [yN]? n
The following system services are available::
1. mongodb
2. mysql
3. redis
Please select one you wish to provision: 2
Specify the name of the service [mysql-4a958]: 
Creating Service: OK
Binding Service: OK
Uploading Application:
  Checking for available resources: OK
  Processing resources: OK
  Packing application: OK
  Uploading (77K): OK   
Push Status: OK
Staging Application: OK                                                         
Starting Application: OK

Note that vmc provisioning and linked a new MySQL instance with the app!

Now, let's see what Drawbridge is all about. Visiting http://example104.cloudfoundry.com in my browser, I can work on a collaborative whiteboard (much like Gobby or Etherpad, except for drawing pictures). Brian Thomason helped me create this Pulitzer-worthy doodle:


Listing Apps and Services

Now that I have a few apps and services running, I can take a look at what I have running using a few basic vmc commands.

Here are my apps:

$ vmc apps 
+-------------+----+---------+-----------------------------+-------------+
| Application | #  | Health  | URLS                        | Services    |
+-------------+----+---------+-----------------------------+-------------+
| example102  | 1  | RUNNING | example102.cloudfoundry.com |             |
| example103  | 1  | RUNNING | example103.cloudfoundry.com |             |
| example101  | 1  | RUNNING | example101.cloudfoundry.com |             |
| example104  | 1  | RUNNING | example104.cloudfoundry.com | mysql-4a958 |
+-------------+----+---------+-----------------------------+-------------+

And my services (available and provisioned):

$ vmc services 
============== System Services ==============
+---------+---------+-------------------------------+
| Service | Version | Description                   |
+---------+---------+-------------------------------+
| redis   | 2.2     | Redis key-value store service |
| mongodb | 1.8     | MongoDB NoSQL store           |
| mysql   | 5.1     | MySQL database service        |
+---------+---------+-------------------------------+
=========== Provisioned Services ============
+-------------+---------+
| Name        | Service |
+-------------+---------+
| mysql-4a958 | mysql   |
| mysql-5894b | mysql   |
+-------------+---------+

In this post, I've demonstrated a couple of frameworks (Ruby/Sinatra, NodeJS, Spring/Java), but here I can see that there are several others supported:

$ vmc frameworks 
+---------+
| Name    |
+---------+
| rails3  |
| sinatra |
| lift    |
| node    |
| grails  |
| spring  |
+---------+

Scaling Instances

One of the huge advantages of PaaS deployment is how trivial application resource scalability can actually be. Let's increase the memory available to one of these applications:

$ vmc mem example101
Update Memory Reservation? [Current:128M] (64M, 128M, 256M or 512M) 512M
Updating Memory Reservation to 512M: OK
Stopping Application: OK
Staging Application: OK                                                         
Starting Application: OK   
$ vmc stats example101
+----------+-------------+----------------+--------------+--------------+
| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime       |
+----------+-------------+----------------+--------------+--------------+
| 0        | 0.1% (4)    | 16.9M (512M)   | 40.0K (2G)   | 0d:0h:1m:22s |
+----------+-------------+----------------+--------------+--------------+

Done! Wow, that was easy!

Now, let's add some additional instances, as I suspect they'll crash once my billions of blog readers start pound Drawbridge, maybe it'll stay up a bit longer :-)

$ vmc instances example104 4
Scaling Application instances up to 4: OK
$ vmc stats example104
+----------+-------------+----------------+--------------+---------------+
| Instance | CPU (Cores) | Memory (limit) | Disk (limit) | Uptime        |
+----------+-------------+----------------+--------------+---------------+
| 0        | 0.0% (4)    | 21.0M (128M)   | 28.0M (2G)   | 0d:0h:19m:33s |
| 1        | 0.0% (4)    | 15.8M (128M)   | 27.9M (2G)   | 0d:0h:2m:38s  |
| 2        | 0.0% (4)    | 16.3M (128M)   | 27.9M (2G)   | 0d:0h:2m:36s  |
| 3        | 0.0% (4)    | 15.8M (128M)   | 27.9M (2G)   | 0d:0h:2m:37s  |
+----------+-------------+----------------+--------------+---------------+

In Conclusion

I hope this helps at least a few of you with an introduction to PaaS, CloudFoundry, and the CloudFoundry-Client (vmc) in Ubuntu.  As I said above, stay tuned for a post coming soon about hosting your own CloudFoundry-Server on Ubuntu!

:-Dustin

Printfriendly