Bootstrap BOSH 2.0 with local VirtualBox

Do you feel a little bit disappointed when you can not simply run vagrant up to bring up a bosh-lite on your local environment anymore? Anyways I did. Not for long though. This blog will show you how to bring up a BOSH-Lite directly on your VirtualBox using bosh2 quickly.

Requirements on your machine

  1. 8GB RAM and 100GB free disk space (smaller configurations may work)
  2. Install VirtualBox
    Run the following command to check you are on VirtualBox 5.1+ since previous versions had a network connectivity bug.
$ VBoxManage --version
  1. Install Bosh2 CLI
    https://bosh.io/docs/cli-v2.html
 alias bosh=bosh2

Install Bosh-Lite Director

git clone https://github.com/cloudfoundry/bosh-deployment
cd bosh-deployment

The command below will create your BOSH-Lite env using the bosh.yml as the base manifest while loading manifest operations from all the other .yml-files specified by -o command options and setting variables such as director name, director IP, gateway and network using -v command options. It will create state.json (for recording the latest running state) and creds.yml (for credentials and certs) in your bosh-deployment directory. It also will automatically create/enable Host-only network 192.168.50.0/24 and NAT network ‘NatNetwork’ with DHCP enabled.

bosh2 create-env bosh.yml \
  --state ./state.json \
  -o virtualbox/cpi.yml \
  -o virtualbox/outbound-network.yml \
  -o bosh-lite.yml \
  -o bosh-lite-runc.yml \
  -o jumpbox-user.yml \f
  --vars-store ./creds.yml \
  -v director_name="Bosh Lite Director" \
  -v internal_ip=192.168.50.6 \
  -v internal_gw=192.168.50.1 \
  -v internal_cidr=192.168.50.0/24 \
  -v outbound_network_name=NatNetwork

Setup Alias as vbox

bosh2 -e 192.168.50.6 --ca-cert <(bosh2 int ./creds.yml --path /director_ssl/ca) alias-env vbox

Log into the Director

export BOSH_CLIENT=admin
export BOSH_CLIENT_SECRET=`bosh2 int ./creds.yml --path /admin_password`

Run bosh2 -e vbox env, it equals with running bosh status in Bosh1.

Enable bosh ssh

sudo route add -net 10.244.0.0/16    192.168.50.6 # Mac OS X
sudo route add -net 10.244.0.0/16 gw 192.168.50.6 # Linux
route add           10.244.0.0/16    192.168.50.6 # Windows

SSH to the Director as jumpbox User

bosh2 int ./creds.yml --path /jumpbox_ssh/private_key > ~/.ssh/bosh-virtualbox.key
chmod 600 ~/.ssh/bosh-virtualbox.key
ssh -i ~/.ssh/bosh-virtualbox.key [email protected]

Want to run Cloud Foundry on the BOSH you just deployed? Hooray!

Read the next article Running Cloud Foundry on BOSH2.

Spread the word

twitter icon facebook icon linkedin icon