Cloud Foundry

From DTO Labs Knowledge Base
Jump to: navigation, search

CloudFoundry is a Ruby-based PaaS system that supports the notions of development frameworks, services and clouds.

CloudFoundry is also known as "VCAP", VMware's Cloud Application Platform!

Contents

Architecture

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

Cloudfoundry architecture.png

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:

  1. Create a pristine Ubuntu 10.0.4 VM
  2. Install openssh-server, curl on it (eg, sudo apt-get install openssh-server curl)
  3. 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
  4. 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


Ephemeral filesystem access


Multi-node support?

Life cycle

Nodejs examples

Futher reading

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
Print/export