Cloud Foundry
CloudFoundry is a Ruby-based PaaS system that supports the notions of development frameworks, services and clouds.
- http://cloudfoundry.com Commercial PaaS
- http://cloudfoundry.org Open Source software project (hosted at github) using Apache2 licence
CloudFoundry is also known as "VCAP", VMware's Cloud Application Platform!
Contents |
Architecture
- Request Router
- Like a loadbalancer, it accepts all the HTTP requests for all the applications running in the PaaS and routes them to the best app execution engine that runs the appropriate application code. github code
- Cloud controller
- implements the external API used by tools to load/unload apps and control their environment, including the number of app execution engines that should run each application. (it's a Rails 3 app!). The CLI talks to the Cloud controller. github code
- Services
- Provide data storage and other functions that can be leveraged by applications.
- DEA
- dropplet execution agent. The DEA runs every app as a separate locked down user with reduced privileges and utilizes standard unix/linux security isolation mechanisms. The services each handle multi-tenancy in a way that is appropriate to the service. github code
- Health manager
- Responsible for keeping applications alive and ensuring that if an app execution engine crashes the applications it ran are restarted elsewhere. github code
All these parts are tied together using a simple message bus, which, among other things allows all the servers to find each other.
Also see: Cloud Foundry Open PaaS Deep Dive
Presentations
Command line
vcap CLI
Manages install of VCAP itself.
Usage: vcap [start|stop|restart|tail|status] [COMPONENT] [--no-color] [--config CONFIGDIR]
vmc CLI
Create app, update app, control app
vmc push [appname] [--path] [--url] [--instances N] [--mem] [--no-start] vmc update <appname> [--path PATH] vmc stop <appname> vmc start <appname> vmc target [url]
Update app settings, get app information
vmc mem <appname> [memsize] vmc map <appname> <url> vmc {crashes, crashlogs, logs} <appname> vmc files <appname> [path]
Deal with services, users, and information
vmc create-service <service> [--name servicename] [--bind appname] vmc bind-service <servicename> <appname> vmc unbind-service <servicename> <appname> vmc delete-service <serivcename> vmc user vmc passwd vmc login vmc logout vmc add-user vmc services vmc apps vmc info vmc files <appname> <filename>
For bash completion see: https://github.com/SpringSource/cloudfoundry-samples/tree/master/bash-completion
Trouble Shooting
/tmp/vcap-run$ ls cloud_controller.log health_manager.log mongodb_node.log mysql_node.log redis_node.log dea.log mongodb_gateway.log mysql_gateway.log redis_gateway.log router.log
Building
Installation is (currently) done via software build from the vcap source code in Github. Follow the instructions on the README. You'll basically go through the following steps:
- Create a pristine Ubuntu 10.0.4 VM
- Install openssh-server, curl on it (eg, sudo apt-get install openssh-server curl)
- Run the setup/install script. This build script will kick off a behemoth build including ruby (two versions), erlang, rabbitmq, mongo, and finally vcap stuff itself. On my MBPro took about over 1.5h.
- Note you will be sudo prompted for password if you are not root
- Start the system (eg vcap start)
- Note: be sure to logout and login again to pickup the new environment otherwise you'll get this:
alexh@ubuntu:~/cloudfoundry/vcap$ bin/vcap start /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- nats/client (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from bin/vcap:26 alexh@ubuntu:~/cloudfoundry/vcap$ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
If all is successful, you should see this glorious output:
alexh@ubuntu:~/cloudfoundry/vcap$ bin/vcap start router : RUNNING cloud_controller : RUNNING dea : RUNNING health_manager : RUNNING redis_gateway : RUNNING redis_node : RUNNING mysql_gateway : RUNNING mysql_node : RUNNING mongodb_gateway : RUNNING mongodb_node : RUNNING
Running
Use ``vcap start`` to start up the VCAP
If you've already pushed an app to your running instance list it by running `vmc apps`.
Installing w/Chef-Solo (dev mode)
sudo apt-get update
sudo apt-get -y install git-core
git clone https://github.com/cloudfoundry/vcap.git
cd ~/vcap/dev_setup/bin/
./vcap_dev_setup -a
./vcap_dev start
Test a sample application
vmc target api.vcap.me vmc register --email foo@bar.com --passwd password mkdir env && cd env
Create a env.rb files in the new "env" directory
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
vmc push env --instances 4 --mem 64M --url env.vcap.me -n
curl http://env.vcap.me
Application configuration
Environment variables
- VCAP_SERVICES
- VCAP_APP_INSTANCE contains a json string containing a HOME property useful for knowing what directory the app was deployed
Ephemeral filesystem access
- Local file system access Cloud Foundry Community - How will we get local file system access?
Multi-node support?
Life cycle
- What happens when you vmc push an application to Cloud Foundry
- How Cloud Foundry works when a new Application is Deployed
Nodejs examples
- Getting started with Cloud Foundry using a Node.js and MongoDB application
- NodeJS Hello World example in the comments
Futher reading
- Github cloudfoundry/vcap Source code repository
- Vmware CloudFoundry Architecture Blog post
- VMware CloudFoundry: Ruby powered PaaS Summary
- Cloud Foundry Architecture and Auto-Scaling Blog post from Rightscale
- CloudFoundry YouTube Channel Videos mostly introducing it at product launch
- vmc Getting Started - Cloud Foundry Command Line Interface Video
- A Java geek >> First try with CloudFoundry Introduction
