How to deploy Cloud Foundry on your local machine.

In this article, we’ll look at bosh-lite open source project to deploy CF in a single Virtual Machine (VM) using Vagrant and VirtualBox.

Prerequisites

You must have a mac with 16GB ram.  If you have a proxy please check that you set your proxy settings:

export http_proxy=http://proxy.company.com:8080
export https_proxy=https://proxy.company.com:8080

Installation

Detail instruction how to install CF – https://github.com/cloudfoundry/bosh-lite

I just put commands and detail explanations of common error or warning that I encountered during installation.

  1. Install bosh_cli aka bosh command
    $ gem install bosh_cli
    check version of bosh
    $ bosh -v
    BOSH 1.2827.0
  2. Install Vagrant – http://www.vagrantup.com/downloads.html
    check version of Vagrant
    $ vagrant -v
    Vagrant 1.7.2
  3. Clone bosh-lite repository under ~/workspace/
    $ git clone https://github.com/cloudfoundry/bosh-lite.git
    $ ls ~/workspace/
    bosh-lite
  4. Install VirtualBox – https://www.virtualbox.org/wiki/Downloads
    check version of virtual box
    $ vboxManage -v
    4.3.20r96996
  5. Create new VM
    $ cd ~/workspace/bosh-lite
    $ vagrant up –provider=virtualboxIf have an error:
The box 'cloudfoundry/bosh-lite' could not be found or

could not be accessed in the remote catalog. If this is a private

box on HashiCorp's Atlas, please verify you're logged in via

`vagrant login`. Also, please double-check the name. The expanded

URL and error message are shown below:


URL: ["https://atlas.hashicorp.com/cloudfoundry/bosh-lite"]

Error:

You need to comment or remove code in

/Applications/Vagrant/embedded/gems/gems/vagrant-1.5.2/lib/vagrant/util/subprocess.rb

if @command[0].downcase.include?(installer_dir)
 @logger.info("Command in the installer. Specifying DYLD_LIBRARY_PATH...")
 process.environment["DYLD_LIBRARY_PATH"] =
 "#{installer_dir}/lib:#{ENV["DYLD_LIBRARY_PATH"]}"
 @logger.info("process.environment")
 @logger.info(process.environment["DYLD_LIBRARY_PATH"])
 @logger.info("end process.environment")
else
 @logger.debug("Command not in installer, not touching env vars.")
end
  1. Run bosh Director
    # if behind a proxy, exclude this IP by setting no_proxy
    $ export no_proxy=192.168.50.4,xip.io
    $ bosh target 192.168.50.4 lite
    Target set to `Bosh Lite Director’
    $ bosh login
    Your username: admin
    Enter password: admin
  2. Add a set of route$ bin/add-route
  3. Install Spiff
    $ brew tap xoebus/homebrew-cloudfoundry
    $ brew install spiff
    $ spiff -v
    spiff version 1.0.3
  4. $ cd ~/workspace
    $ git clone https://github.com/cloudfoundry/cf-release
  5. $ cd ~/workspace/cf-release
  6. Upload release
    $ ls releases/
    cf cf-142.yml cf-149.yml cf-156.yml cf-164.yml cf-172.yml cf-180.yml cf-190.yml cf-197.yml
    cf-136.yml cf-143.yml cf-150.yml cf-157.yml cf-165.yml cf-173.yml cf-182.yml cf-191.yml index.yml
    cf-137.yml cf-144.yml cf-151.yml cf-158.yml cf-166.yml cf-175.yml cf-183.yml cf-192.yml
    cf-138.yml cf-145.yml cf-152.yml cf-159.yml cf-168.yml cf-176.yml cf-186.yml cf-193.yml
    cf-139.yml cf-146.yml cf-153.yml cf-160.yml cf-169.yml cf-177.yml cf-187.yml cf-194.yml
    cf-140.yml cf-147.yml cf-154.yml cf-161.yml cf-170.yml cf-178.yml cf-188.yml cf-195.yml
    cf-141.yml cf-148.yml cf-155.yml cf-163.yml cf-171.yml cf-179.yml cf-189.yml cf-196.yml
  7. $ bosh upload release releases/cf-196.yml # according google group 196 last stable release at this moment
    It takes about 30 minutes.
  8. $ wget http://bosh-jenkins-artifacts.s3.amazonaws.com/bosh-stemcell/warden/latest-bosh-stemcell-warden.tgz
  9. $ bosh upload stemcell latest-bosh-stemcell-warden.tgz
  10. $ cd ~/workspace/bosh-lite
    $./bin/make_manifest_spiff
  11. $ bosh deployment manifests/cf-manifest.yml
  12. $ bosh deploy
    # enter yes to confirm
    It takes another 30 minutes or more.

Run test 

You need to run test using the following recommendations  cf-acceptance-tests.
Create integration_config.json that seems like below

{
 "api": "api.10.244.0.34.xip.io",
 "admin_user": "admin",
 "admin_password": "admin",
 "apps_domain": "10.244.0.34.xip.io",
 "skip_ssl_validation": true,
 "persistent_app_host": "myapp",
 "persistent_app_space": "myspace",
 "persistent_app_org": "myorg",
 "persistent_app_quota_name": "myquota",
 "default_timeout": 45,
 "cf_push_timeout": 180,
 "long_curl_timeout": 180,
 "broker_start_timeout": 300
}
  1. $ export CONFIG=~/workspace/integration_config.json
  2. $ mkdir -p ~/go
  3. $ export GOPATH=~/go
  4. $ go get github.com/cloudfoundry/cf-acceptance-tests
  5. $ cd $GOPATH/src/github.com/cloudfoundry/cf-acceptance-tests
  6. $ ./bin/test

After test run you may check CF


$ cf l
API endpoint: https://api.10.244.0.34.xip.io
Email> admin
Password> admin
Authenticating...
OK

Targeted org myorg
Targeted space myspace

API endpoint: https://api.10.244.0.34.xip.io (API version: 2.21.0)
User: admin
Org: myorg
Space: myspace
$ cf domains
Getting domains in org myorg as admin...
name status 
10.244.0.34.xip.io shared
$ cf apps
Getting apps in org myorg / space myspace as admin...
OK
name requested state instances memory disk urls
myapp started 1/1 256M 1G myapp.10.244.0.34.xip.io
 
$ curl http://myapp.10.244.0.34.xip.io/
Hi, I'm Dora!

Create a directory 
$ mkdir test-hi
$ cd test-hi
$ vim test-hi.php
<?php print("Hi, Sergey!"); ?>
$ cf push test-hi
Creating app test-hi in org myorg / space myspace as admin...
OK
Creating route test-hi.10.244.0.34.xip.io...
OK
Binding test-hi.10.244.0.34.xip.io to test-hi...
OK
Uploading test-hi...
Uploading app files from: /Users/212396313/workspace/test-hi
Uploading 164, 1 files
Done uploading
OK
Starting app test-hi in org myorg / space myspace as admin...
-----> Downloaded app package (4.0K)
-------> Buildpack version 1.0.2
Use locally cached dependencies where possible
! WARNING: No composer.json found.
Using index.php to declare PHP applications is considered legacy
functionality and may lead to unexpected behavior.
See https://devcenter.heroku.com/categories/php
-----> Setting up runtime environment...
- PHP 5.5.12
- Apache 2.4.9
- Nginx 1.4.6
-----> Installing PHP extensions:
- opcache (automatic; bundled, using 'ext-opcache.ini')
-----> Installing dependencies...
Composer version ac497feabaa0d247c441178b7b4aaa4c61b07399 2014-06-10 14:13:12
Warning: This development build of composer is over 30 days old. It is recommended to update it by running "/app/.heroku/php/bin/composer self-update" to get the latest version.
Loading composer repositories with package information
Installing dependencies
Nothing to install or update
Generating optimized autoload files
-----> Building runtime environment...
NOTICE: No Procfile, defaulting to 'web: vendor/bin/heroku-php-apache2'
-----> Uploading droplet (64M)
1 of 1 instances running
App started
 
OK
App test-hi was started using this command `vendor/bin/heroku-php-apache2`
Showing health and status for app test-hi in org myorg / space myspace as admin...
OK
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: test-hi.10.244.0.34.xip.io
last uploaded: Wed Feb 11 00:07:11 +0000 2015
state since cpu memory disk
#0 running 2015-02-10 04:07:55 PM 0.7% 92.4M of 256M 0 of 1G
$ cf apps
Getting apps in org myorg / space myspace as admin...
OK
name requested state instances memory disk urls
myapp started 1/1 256M 1G myapp.10.244.0.34.xip.io
test-hi started 1/1 256M 1G test-hi.10.244.0.34.xip.io
 
$ curl test-hi.10.244.0.34.xip.io
Hi, Sergey!

How to handle your Virtual Machine (VM) 

The best practice  to handle VM is to use vagrant commands for Virtual Box.  To suspend your VM when you do not need it for awhile you may use $ vagrant suspend command that saves your VM state at the point of time and VM will stop running.  When you need your VM running again you have to use $ vagrant resume command and then use $ bosh cck command to be sure that CF is working fine.


$ vagrant suspend
==> default: Saving VM state and suspending execution...
$ vagrant resume
==> default: Resuming suspended VM...
==> default: Booting VM...
==>; default: Waiting for machine to boot. This may take a few minutes...
 default: SSH address: 127.0.0.1:2222
 default: SSH username: vagrant
 default: SSH auth method: private key
 default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
$ bosh cck
Performing cloud check...
Processing deployment manifest
------------------------------
Director task 8
Started scanning 14 vms
Started scanning 14 vms > Checking VM states. Done (00:00:00)
Started scanning 14 vms > 14 OK, 0 unresponsive, 0 missing, 0 unbound, 0 out of sync. Done (00:00:00)
Done scanning 14 vms (00:00:00)
Started scanning 3 persistent disks
Started scanning 3 persistent disks > Looking for inactive disks. Done (00:00:00)
Started scanning 3 persistent disks > 3 OK, 0 missing, 0 inactive, 0 mount-info mismatch. Done (00:00:00)
Done scanning 3 persistent disks (00:00:00)
Task 8 done
Started 2015-02-12 19:04:42 UTC
Finished 2015-02-12 19:04:42 UTC
Duration 00:00:00
Scan is complete, checking if any problems found...
No problems found

How to integrate local CF into Eclipse

Go to Server view> New > Server take Pivotal\Cloud Foundry

Screen Shot 2015-02-13 at 2.38.59 PM
Enter account information
email: admin
Password: admin
URL: https://api.10.244.0.34.xip.io

Screen Shot 2015-02-13 at 2.39.38 PM

After that you may handle your local CF from Eclipse view.

Screen Shot 2015-02-12 at 12.11.11 PM

Useful Links 

Detail instruction how to install CF (Bosh Lite) – https://github.com/cloudfoundry/bosh-lite

Current status Cloud Foundry project – https://groups.google.com/a/cloudfoundry.org/forum/#!topic/vcap-dev/JjcdDRGBcnk

Getting Started with the CF

Troubleshooting CF

Advertisements

5 thoughts on “How to deploy Cloud Foundry on your local machine.

  1. Hey, Thank you for this nice step by step guide. I just finished installing local cloud foundry.
    Now I am trying to deploy the hello-spring-cloud from https://github.com/cloudfoundry-samples/hello-spring-cloud in my local vm. But this sample application needs 4 services.
    Do I need to create those services in my local vm. I could not find a guide on how to do that.

    I see that you have a guide to install mysql in local vm. I need to figure out the postgres services first. When I type bosh vms, I see that there is already a postgres_z1/0 job running.

    Can you please provide some guidance here? How to deploy apps which have dependency on relational db and queues for example in my local cloud foundry vm.

  2. Pingback: Cómo instalar Cloud Foundry en local (Ubuntu) | David Muñoz Fernández

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s