NTT, the world’s leading telecom, has been active in fostering the Cloud Foundry developer and user community in Japan. We’re excited about NTT Lab’s latest open source community contribution to Cloud Foundry – Nise BOSH, a lightweight BOSH emulator for locally compiling, releasing and testing services. BOSH is an open source tool chain for release engineering, deployment and lifecycle management of large-scale distributed applications and services, such as Cloud Foundry. Nise BOSH allows developers and cloud operators who use BOSH to speed up the development feedback cycle while saving effort and money. In this post, we’ll explain how all this works and why it’s useful.
Normal BOSH Deploy Cycle
When you do a
bosh deploy of a large scale distributed service such as Cloud Foundry to a cluster, BOSH does a number of things on your behalf:
- Prepares deployment
- Compiles packages – Calculates all packages and their dependencies that need to be compiled. It then begins compiling the packages and storing their output in the blobstore. The number of
workersspecified in the deployment configuration determines how many VMs can be created at once for compiling.
- Prepares DNS
- Creates bound missing VMs – Creates new VMs, deletes extra VMs.
- Binds instance VMs
- Prepares configuration
- Updates/deletes jobs – Deletes unneeded instances, creates needed instances, updates existing instances if they are not already updated. This is the step where things get pushed live.
In step #2 BOSH spins up a number of worker VMs to compile your code packages, then installs your compiled code in one or more VMs called stemcells. Normally all of these VMs are running somewhere on an IaaS provider such as VMware vSphere or AWS EC2.
Using Nise BOSH to Speed Up the Feedback Cycle
This is great in production, but when iterating on a BOSH Package, spinning up multiple VMs for compilation and deployment makes for a slow feedback cycle and a lot of ssh’ing into servers. It can also be costly, as you may have to pay for development resources on an IaaS, e.g. on AWS. Nise BOSH is a great help when developing a BOSH package. A Package is a collection of source code along with a script that contains instruction how to compile it to binary format and install it, with optional dependencies on other pre-requisite packages. Without Internet access or an IaaS, Nise BOSH will compile the packages necessary to run the job and install them on the box that you’re on, saving you the time, expense and complexity of using remote resources on AWS or another IaaS. Let’s see how this works.
First, start on a machine that looks like your target Stemcell. A Stemcell is a VM template with an embedded BOSH Agent. The Stemcell used for Cloud Foundry is a standard Ubuntu distribution. For this you can use Vagrant, a handy tool to create easily reproducible environments on your local laptop. Install Vagrant and then in a terminal:
$ vagrant init lucid64 http://files.vagrantup.com/lucid64.box $ vagrant up $ vagrant ssh
You should now be in an Ubuntu lucid64 environment on your local machine. Now install Nise BOSH –
$git clone email@example.com:nttlabs/nise_bosh.git $cd nise_bosh $bundle install
Next you need to get a BOSH Cloud Foundry release – a BOSH release is a collection of source code, configuration files and startup scripts used to run services, along with a version number that uniquely identifies the components.
$git clone firstname.lastname@example.org:cloudfoundry/cf-release.git $cd cf-release $git submodule sync $git submodule update --init --recursive
You can now modify the Cloud Foundry open source code in cf-release/src as your project needs require. Once you are ready to test your changes, you need to create the release, but first install the BOSH CLI –
$gem install bosh_cli $bosh create release
Before you can deploy your release you’ll need a BOSH manifest file we’ll call deploy.conf. An example of the contents for a Nise BOSH manifest can be found in the Nise BOSH doc.
Now run Nise BOSH from the nise_bosh directory to launch dea_next. Without Internet access or an IaaS, Nise BOSH will compile the packages necessary to run the job and install them on the box that you’re on. Then just run
run-job start to start the jobs in /var/vcap/bosh/etc/monitrc locally on your box.
$sudo PATH=$PATH bundle exec ./bin/nise-bosh ~/cf-release ~/deploy.conf dea_next $./bin/run-job start
Nise BOSH is all set up to help you play with dea_next all by itself, but eventually it might enable to you develop and run Cloud Foundry right on your local machine. We see the many community contributions like NTT Nise BOSH as proof of the power of an Open PaaS ecosystem to advance the project. Next time you’re working on a BOSH release, give it a try.
About the Author