Deploying Bosh on Ubuntu
Run Bosh Director locally on VM using Virtual Box on Ubuntu
This guide is useful for the developers who are learning BOSH and want to run BOSH on VM using Virtual Box on Ubuntu. BOSH provide BOSH Lite which as the name suggests is light version of BOSH. To run BOSH you will need to install BOSH CLI on Ubuntu.
Assumption
- Virtual Box is already installed on the machine.
- User has root privileges on the machine.
Installing BOSH CLI on Ubuntu
Unfortunatelly BOSH does not provide CLI with apt
or yum
, so we will need to download it from their git release.
Please follow the below steps:
- Go to their git release page, and download the latest (or required) version's
*-linux-amd-64
file. - Rename the downloaded file to
bosh
. - Make the file executable by running the command
chmod +x ./bosh
- Move the file to one of the directories in your PATH folder. My preference is
sudo mv ./bosh /usr/local/bin/bosh
- To check if the whole process worked, run the command
bosh -v
and check the output.
1version 6.2.1-a28042ac-2020-02-10T18:40:57Z
2
3Succeeded
Congratulations you have successfully installed BOSH CLI on you ubuntu machine.
Installing dependencies
To run BOSH director on Virtual Box you will need to compile some packages which have some dependencies. Depending on you Ubuntu Version please follow the next steps:
Ubuntu Xenial(16.04) or Ubuntu Trusty (14.04)
1sudo apt-get install -y build-essential zlibc zlib1g-dev ruby ruby-dev openssl libxslt-dev libxml2-dev libssl-dev libreadline6 libreadline6-dev libyaml-dev libsqlite3-dev sqlite3
Ubuntu Bionic(18.04)
1sudo apt-get install -y build-essential zlibc zlib1g-dev ruby ruby-dev openssl libxslt1-dev libxml2-dev libssl-dev libreadline7 libreadline-dev libyaml-dev libsqlite3-dev sqlite3
Make sure you have installed these packages on your machine. Highly possible that you might already have few of them installed before.
Install Director VM
To install/ run the BOSH director VM we will clone the official bosh release from git. Now from here on we are assuming some default paths on machine which feel free to modify as per your requirement.
1git clone https://github.com/cloudfoundry/bosh-deployment ~/workspace/bosh-deployment
2mkdir -p ~/deployments/vbox
3cd ~/deployments/vbox
Now run the following command to create a BOSH director on VM running on Virtual Box using BOSH CLI.
1bosh create-env ~/workspace/bosh-deployment/bosh.yml \
2 --state ./state.json \
3 -o ~/workspace/bosh-deployment/virtualbox/cpi.yml \
4 -o ~/workspace/bosh-deployment/virtualbox/outbound-network.yml \
5 -o ~/workspace/bosh-deployment/bosh-lite.yml \
6 -o ~/workspace/bosh-deployment/bosh-lite-runc.yml \
7 -o ~/workspace/bosh-deployment/uaa.yml \
8 -o ~/workspace/bosh-deployment/credhub.yml \
9 -o ~/workspace/bosh-deployment/jumpbox-user.yml \
10 --vars-store ./creds.yml \
11 -v director_name=bosh-lite \
12 -v internal_ip=192.168.50.6 \
13 -v internal_gw=192.168.50.1 \
14 -v internal_cidr=192.168.50.0/24 \
15 -v outbound_network_name=NatNetwork
Since this command will take some time, we can shortly discuss what is going on with the command.
Here bosh
cli is going to use a bosh.yml
file as a deployment manifest, which contains instruction on what to do.
The state of the BOSH's director's deployment will be stored in state.json
file.
Than you are using bunch of Ops Files which are used to provide additional information or modify information provided by Manifest File.
The secrets to access the BOSH direct which is going to run in some time is stored in creds.yml
file.
Than some requrired variables are passed to the command line.
Behind the scenes BOSH Command will autmatically try to create/ enable Host-Only network 192.168.50.0/24 and NAT network with DHCP enabled.
If the command above ends with an error, it is possible that the bosh intialisation takes more time than timout, but worry not run the command again and it should work.
Hint
Some times the credhub job does not start in the BOSH director's VM with error Could not reach the UAA server
.
This is caused by slow response from UAA's health check endpoint. So you can force start credhub with an ops file.
The content of Ops File is provided below, which will make sure that credhub starts without waiting for uaa to start.
1- path: /instance_groups/name=bosh/jobs/name=credhub/properties/credhub/authentication/uaa/wait_for_start?
2 type: replace
3 value: false
Connecting to BOSH
Please run the below commands to connect to BOSH directo using bosh
cli:
1export BOSH_CLIENT=admin
2export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
3bosh alias-env vbox -e 192.168.50.6 --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
And check if it works by running
1bosh -e vbox env
2# Using environment '192.168.50.6' as '?'
3#
4# Name: ...
5# User: admin
6# Succeeded
Congrats you now have a running BOSH director.