Today: February 14, 2025 10:14 pm
A collection of Software and Cloud patterns with a focus on the Enterprise

Explore CloudFoundry using bosh-lite on Windows

It seems like most of the development around CloudFoundry and bosh happen on Linux or Mac. Getting things up and running in Windows was a real challenge. Below is how I worked things out.

**Make sure you have a modern processor that supports all virtualization technologies, such as VTx and extended paging.

Aside from the deviations mentioned below, I’m following the steps documented at https://github.com/cloudfoundry/bosh-lite

Changes to Vagrantfile

I’m using VirtualBox on Windows 7. To begin with, I modified the Vagrantfile to create two VMs rather than a single VM. The first is the VM that will run CloudFoundry. The second is to run bosh for the deployment of CloudFoundry. I use a second Linux VM to execute the bosh deployment since all the commands and files were developed in a *nix environment.

I am also more explicit in my network setup. I want the two hosts to have free communication on a local private network. I leave the default IP address assignment for the CloudFoundry host. For the bosh host I change the last octet of the IP address to 14.

  config.vm.define "cf" do |cf|
    cf.vm.provider :virtualbox do |v, override|
      override.vm.box = 'cloudfoundry/bosh-lite'
      override.vm.box_version = '388'
 
      # To use a different IP address for the bosh-lite director, uncomment this line:
      override.vm.network :private_network, ip: '192.168.50.4', id: :local
      override.vm.network :public_network
    end
  end
 
  config.vm.define "boshlite" do |boshlite|
    boshlite.vm.provider :virtualbox do |v, override|
      override.vm.box = 'ubuntu/trusty64'
 
      # To use a different IP address for the bosh-lite director, uncomment this line:
      override.vm.network :private_network, ip: '192.168.50.14', id: :local
      override.vm.network :public_network
      v.memory = 6144
      v.cpus = 2
    end
  end

At this point you can spin up the two hosts.

vagrant up --provider=virtualbox

The remaining steps need to happen on your bosh deployment host (192.168.0.14 based on the Vagrantfile above). In case you need it, here is a refresher on setting up Vagrant SSH connectivity using PuTTY on Windows.

Prepare for provision_cf

If you are in a proxied environment, you’ll need to set the environment variables, including no_proxy for the CloudFoundry host. I include xip.io for ease of access in future steps.

export http_proxy=http://proxy.domain.com:8080
export https_proxy=https://proxy.domain.com:8080
export no_proxy=192.168.50.4,xip.io

Next we need to get prerequisites going and then install the bosh CLI. You may have some of these already, and you may need some additional libraries. This is based on a clean Ubuntu trusty 64 box.

sudo -E add-apt-repository multiverse
sudo -E apt-get update
sudo -E apt-get -y install build-essential linux-headers-`uname -r`
sudo -E apt-get -y install ruby ruby-dev git zip

Now bosh_cli can be installed. I’ve added flags to skip ‘ri’ and ‘rdoc’ since they take a long time. If you really want those, you can drop those arguments.

sudo -E gem install bosh_cli --no-ri --no-rdoc

We also need spiff on this system. Here I grab and unzip the latest spiff, then move the binary into /usr/local/bin.

wget https://github.com/cloudfoundry-incubator/spiff/releases/download/v1.0.3/spiff_linux_amd64.zip
unzip spiff_linux_amd64.zip
sudo mv spiff /usr/local/bin/

Next we need to clone both bosh-lite and cf-release. Even though the contents of bosh-lite are available in “/vagrant”, we need these two directories side by side, so it’s easiest to just clone them both into the home directory of the bosh deployment host. We then change into the bosh-lite directory.

git clone https://github.com/cloudfoundry/bosh-lite.git
git clone https://github.com/cloudfoundry/cf-release
cd bosh-lite/

The script ./bin/provision_cf needs to be edited so that get_ip_from_vagrant_ssh_config simply outputs the private network IP address that was assigned in the Vagrant file. The default functionality assumes that the provision script is run from the the host running Vagrant and VirtualBox. However, these commands are running on the bosh deployment host, which doesn’t know anything about vagrant or virtualbox. Here’s what the function should look like.

get_ip_from_vagrant_ssh_config() {
  echo 192.168.50.4
}

Target bosh and provision

Everything is set to target the bosh host, set the route and provision CloudFoundry. When you first target the cloudfoundry host, it will as for credentials to login.

vagrant@vagrant-ubuntu-trusty-64:~/bosh-lite$ bosh target 192.168.50.4 lite
Target set to `Bosh Lite Director'
Your username: admin
Enter password: *****
Logged in as `admin'

Next we can add the route to the bosh deployment host.

vagrant@vagrant-ubuntu-trusty-64:~/bosh-lite$ ./bin/add-route
Adding the following route entry to your local route table to enable direct warden container access. Your sudo password may be required.
  - net 10.244.0.0/19 via 192.168.50.4

Provision CloudFoundry

The only thing left to do is provision CloudFoundry.

./bin/provision_cf
...
Started         2014-09-29 18:54:39 UTC
Finished        2014-09-29 19:36:11 UTC
Duration        00:41:32
 
Deployed `cf-manifest.yml' to `Bosh Lite Director'

This takes quite a while (possibly hours depending on your hardware). If you have an older processor that doesn’t support all the modern virtualization technologies, this could take much longer.

Verify your new CloudFoundry deployment

In order to use CloudFoundry we need the ‘cf’ client. The cf client is available as a binary download from the main GitHub page for CloudFoundry. The following commands will prepare the cf CLI for use.

wget http://go-cli.s3-website-us-east-1.amazonaws.com/releases/v6.6.1/cf-linux-amd64.tgz
tar xzvf cf-linux-amd64.tgz
sudo mv cf /usr/local/bin/

With the cf CLI installed, it is now possible connect to the API and setup org and space details.

cf api --skip-ssl-validation https://api.10.244.0.34.xip.io
cf auth admin admin
cf create-org myorg
cf target -o myorg
cf create-space mydept
cf target -o myorg -s mydept

You should now have an environment that matches the below.

API endpoint:   https://api.10.244.0.34.xip.io (API version: 2.14.0)
User:           admin
Org:            myorg
Space:          mydept

Deploy an app

You can now deploy an application. To verify, create a directory can add a file:

index.php

<?php phpinfo(); ?>

Now push that app as follows:

vagrant@vagrant-ubuntu-trusty-64:~/test-php$ cf push test-php
Creating app test-php in org myorg / space mydept as admin...
OK
 
Creating route test-php.10.244.0.34.xip.io...
OK
 
Binding test-php.10.244.0.34.xip.io to test-php...
OK
 
Uploading test-php...
Uploading app files from: /home/vagrant/test-php
Uploading 152, 1 files
OK
 
Starting app test-php in org myorg / space mydept as admin...
OK
-----> Downloaded app package (4.0K)
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)
 
0 of 1 instances running, 1 starting
1 of 1 instances running
 
App started
 
Showing health and status for app test-php in org myorg / space mydept as admin...
OK
 
requested state: started
instances: 1/1
usage: 256M x 1 instances
urls: test-php.10.244.0.34.xip.io
 
     state     since                    cpu    memory          disk
#0   running   2014-09-29 07:52:38 PM   0.0%   84.9M of 256M   0 of 1G

It’s now possible to view the app using a browser. From the command line you can access it using this command:

w3m http://test-php.10.244.0.34.xip.io

Observations

In my tests, the xip.io resolution was flaky. I saw intermittent failures with the response:

dial tcp: lookup api.10.244.0.34.xip.io: no such host

In some cases I would have to run the same command a few times before it could resolve the host.

The VMs I setup obtained IP addresses on my network. However, when I tried to access apps or the API over that IP address, the connection is refused. Despite adding the domain (e.g. dhcpip.xip.io) to CloudFoundry and creating routes to my application, all attempts to use the API or load apps over the external IP failed.

Comments

  1. […] CloudFoundry on HPCloud.com Install CloudFoundry in VirtualBox […]

  2. […] this exercise I deployed bosh-lite on my Windows 7 laptop. I then follow the documented procedure to push cf-echo-service and cf-service-broker-python to […]

  3. Thanks Daniel for this enormously helpful post.

    In additon to the prereqs specified, I had to install zlib1g-dev in order to get bosh_cli to install.

    And for anyone else who is using cntlm on their Windows box to authenticate to an NTLM proxy, the proxy settings would be:

    export http_proxy=http://10.0.2.2:3128
    export https_proxy=http://10.0.2.2:3128
    export no_proxy=192.168.50.4,xip.io

    Cheers,

    Robb

  4. Avatar for Daniel Watrous David Damon : May 21, 2015 at 4:13 pm

    I just ran across this. Thanks. It was very helpful. It may be the newer versions of the image image files, but, I had to do this
    sudo -E apt-get install zlibc zlib1g zlib1g-dev

    before:
    sudo -E gem install bosh_cli –no-ri –no-rdoc

    The zlib library was missing for libxml2 when building native extensions.

  5. An error ocurred while I’m executing command “cf api”, using VirtualBox, as follows:

    root@vagrant-ubuntu-trusty-64:/home/vagrant# cf api –skip-ssl-validation https://api.10.244.0.34.xip.io
    Setting api endpoint to https://api.10.244.0.34.xip.io
    FAILED
    Error performing request: Get https://api.10.244.0.34.xip.io/v2/info: dial tcp 10.244.0.34:443: i/o timeout

  6. Hi Daniel,

    I followed the above steps but when I am trying to set an api end point by using the command
    cf api –skip-ssl-validation https://api.10.244.0.34.xip.io, it fails and says no route to host.

    Can you please help me with this?

    Thanks & Regards,
    Sujeet Yadav

  7. Regarding above failures.
    I was curious if anyone here, has successfully set up their local CF instance and been able to use the STS plugin to deploy apps to their local CF instance running on the VM.

  8. Avatar for Daniel Watrous Pankaj Kulkarni : June 2, 2016 at 9:34 am

    Hi Daniel

    This link was very helpful.. since it’s not possible to run spiff on windows any more.

    I was trying to access CF installation using

    api.10.244.0.34.xip.io

    but it did not work for me.

    after that I tried

    cf api –skip-ssl-validation https://api.bosh-lite.com

    and it worked.

    Thanks for the great article.

    -Pankaj

  9. Hi Daniel,

    Great tutorial.

    I wonder which versions of CF and Bosh are used. Also, when I perform the provision_cf step I get at the Generating bosh lite manifest step:
    from /home/vagrant/cf-release/scripts/generate-bosh-lite-dev-manifest
    Bundler is not installed; install it with `gem install bundler`
    After the installation of bundler I get:
    /var/lib/gems/1.9.1/gems/bosh_cli-1.3262.26.0/bin/optionally_run_with_bundler.rb:22:in `write’: Permission denied.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.