As you may be aware, VMware’s Cloud Foundry is an open source “Platform as a Service” (PaaS) on which you can “deploy and scale your application in seconds.” In anticipation of my presentation at STIC 2012, I have been learning about Cloud Foundry and this blog post describes my initial steps, using material from cloudfoundry.com and from github.com.
I started by registering for an account because I wanted to try deploying on VMware’s cloud (this step is not necessary for our later deployment on a private cloud). The confirmation email took several hours to come, and I’ve read of others who waited for days, so if you register don’t be surprised if it takes a while to hear back.
On a clean install of Snow Leopard (Mac 10.6), I started by creating a very simple Sinatra application in Ruby. (Of course, the goal of this project is to deploy Smalltalk to the cloud, but we will start with things that Cloud Foundry understands, and go from there!) In a Terminal, I entered the following commands (providing my password when prompted):
sudo gem install mime-types sudo gem install rubyzip sudo gem install uuidtools sudo gem install sinatra mkdir env; cd env
In ~/env/ I created a file, env.rb, consisting of the following text:
require 'rubygems' require 'sinatra'
get '/' do host = ENV['VMC_APP_HOST'] port = ENV['VMC_APP_PORT'] "<h1>XXXXX Hello from the Cloud! via: #{host}:#{port}</h1>" end
get '/env' do res = '' ENV.each do |k, v| res << "#{k}: #{v}<br/>" end res end
Then, from the Terminal, I entered the following command:
ruby env.rb
This told me that Sinatra was running a web server on port 4567, so I opened a web browser on http://localhost:4567/env and verified that my application ran and returned the expected values. I used <Ctrl>+<C> in the Terminal to terminate the application.
The next task was to install the command-line tools (vmc) used to interact with Cloud Foundry. In the Terminal I entered the following command:
sudo gem install vmc --pre
The ‘–pre’ option tells ruby to install the pre-release version of vmc. Next, I specified the target cloud for deployment, I logged in using the email address and the password I got when I registered (see above), and I pushed the application to the cloud:
vmc target api.cloudfoundry.com vmc login vmc push
The push command prompts a series of questions. I accepted the default (Y) to deploy from the current directory. I gave a unique name for the application (‘jfoster-env’). I accepted the default to confirm that this is a Sinatra application and it can be deployed in 128M of RAM. I specified two (2) instances so I could see the application run on two machines. Finally, I accepted the default to confirm that I did not need any services and I did not need to save the configuration. The tools then proceeded to confirm that the application was pushed and started successfully. In a web browser, I went to the designated location, http://jfoster-env.cloudfoundry.com/, and found that my application was indeed running. I refreshed the page a few times and confirmed that the application was running on two machines (showing different internal IP addresses and ports).
I tried a number of commands to explore what was available through the vmc command-line tools:
vmc help vmc user vmc target vmc info vmc runtimes vmc frameworks vmc apps vmc instances jfoster-env +2 vmc apps vmc instances jfoster-env -2 vmc stats jfoster-env vmc logs jfoster-env vmc files jfoster-env vmc files jfoster-env app vmc files jfoster-env logs vmc env jfoster-env vmc stop jfoster-env vmc apps vmc delete jfoster-env vmc apps vmc logout
In all of this, we have been interacting with the VMware public cloud. The next blog post will explore creating and using a private development cloud.
9 comments
Comments feed for this article
January 26, 2012 at 3:09 pm
Creating a Private Cloud « Programming Gems (on GemStone)
[…] the previous post, I described how to use the vmc command-line tools to deploy a Ruby application to VMware’s […]
January 31, 2012 at 6:07 pm
Adding a Runtime and Framework to an older Cloud Foundry « Programming Gems (on GemStone)
[…] We name the app ‘perl-env’ and otherwise accept the defaults. In a web browser, navigate to http://perl-env.vcap.me/ and observe the application in operation. At this point you should be able to try the various commands listed at the end of this post. […]
February 14, 2012 at 9:26 pm
Preparing Smalltalk for Cloud Foundry « Programming Gems (on GemStone)
[…] Our first exposure to Cloud Foundry used a Ruby runtime and a Sinatra framework where a single file contained source code was copied to the server. In our subsequent example with Perl, the application was represented by a couple Perl files containing source code that was copied to the server. In each case the runtime and framework were in other directories, separate from our application on both the client and the server. […]
February 17, 2012 at 7:02 am
Node.js, ASP.NET, & Sinatra, Rails, Java, The List Goes On: Removing the OS Barrier with PaaS Part 3.14159265 | New Relic blog
[…] Foundry enabled PaaS systems. Rails was one of the first platforms enabled on Cloud Foundry.* Getting Started with Cloud Foundry via GemStones * Setting Up Sinatra with Cloud Foundry * Sinatra (with Redis) on Cloud Foundry (video) * Setting […]
February 19, 2012 at 10:47 pm
Video: Getting Started with Cloud Foundry « Programming Gems (on GemStone)
[…] 5-minute video demonstrates the steps described here. Like this:LikeBe the first to like this post. […]
March 12, 2012 at 12:48 pm
Adding GemStone as a Service to Cloud Foundry « Programming Gems (on GemStone)
[…] verify that Cloud Foundry handles the new service by pushing our original Ruby application (created here) and adding a gemstone service as part of the push process. Once the application is running, go to […]
July 1, 2013 at 3:05 pm
Getting Started With Cloud Foundry 2 | Programming Gems (on GemStone)
[…] has been out for a couple years and I’ve been blogging about it for about 18 months (starting here). Cloud Foundry has moved from VMware to Pivotal and continues to undergo rapid development. […]
February 10, 2014 at 12:09 am
Mark Littlejohn
VMC is not longer current for cloud foundry….would be great if this could be updated with the appropriate new cf
February 10, 2014 at 10:08 am
James Foster
This was my first blog post about Cloud Foundry. You can see the following 21 months of work at https://programminggems.wordpress.com/category/cloud-foundry/. Unfortunately, my recent responsibilities have not left much room for Cloud Foundry, and it is a rapidly changing area!