The BOSH CLI v2 greatly enhances the interaction and deployment of Cloud Foundry and other BOSH releases. The new release, at time of writing still in beta, is now written in Golang, which allows it to be distributed by a simply binary without dependencies. There is even support for Windows planned, though binaries are currently not distributed. There are quite a few changes in the CLI commands, check them out here. The CLI now also includes a mechanism to bootstrap the BOSH Director, which was done previously by using bosh-init or for bosh-lite with a Vagrantfile.
This post will walk you through the required steps to deploy bosh-lite on Virtualbox and deploy Cloud Foundry. Bosh-lite is a single VM development environment which deploys bosh releases in garden containers.
- 8GB memory recommended
- Linux or Mac
- Windows is coming
- cf cli
BOSH CLI v2
First of all we need to download the latest BOSH CLI v2. You can find the latest version here.
After than we make the CLI globally accessible:
chmod +x ~/Downloads/bosh-cli-* sudo mv ~/Downloads/bosh-cli-* /usr/local/bin/bosh
BOSH Director Deployment
We need the bosh-deployment repository which holds a collection of BOSH manifests. Furthermore we are creating a dirctory to hold some deployment specific configuration files.
git clone https://github.com/cloudfoundry/bosh-deployment ~/workspace/bosh-deployment mkdir -p ~/deployments/vbox cd ~/deployments/vbox
The next step is already to bootstrap the bosh-lite director to your local Virtualbox installation. You can modify the network information if you like.
bosh create-env ~/workspace/bosh-deployment/bosh.yml \ --state ~/deployments/vbox/state.json \ -o ~/workspace/bosh-deployment/virtualbox/cpi.yml \ -o ~/workspace/bosh-deployment/virtualbox/outbound-network.yml \ -o ~/workspace/bosh-deployment/bosh-lite.yml \ -o ~/workspace/bosh-deployment/bosh-lite-runc.yml \ -o ~/workspace/bosh-deployment/jumpbox-user.yml \ --vars-store ~/deployments/vbox/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
Lastly we are creating an bosh environment alias and a few environmental variables to reduce the amount to type. You also want to recreate these variables if you create a new shell.
bosh -e 192.168.50.6 --ca-cert <(bosh int ~/deployments/vbox/creds.yml --path /director_ssl/ca) alias-env vbox export BOSH_CA_CERT=$(bosh int ~/deployments/vbox/creds.yml --path /director_ssl/ca) export BOSH_CLIENT=admin export BOSH_CLIENT_SECRET=$(bosh int ~/deployments/vbox/creds.yml --path /admin_password) export BOSH_ENVIRONMENT=vbox
Cloud Foundry Deployment
We are going to use cf-deployment for deploying Cloud Foundry. The repository is still in its early stages but allows us to easily deploy Cloud Foundry, using Diego, in one simple step. It looks like it will be the successor of cf-release and diego-release .
First we are cloning the repository:
git clone https://github.com/cloudfoundry/cf-deployment ~/workspace/cf-deployment cd ~/workspace/cf-deployment
The next step is to upload the required bosh-lite stemcell., which is referenced at the bottom of cf-deployment.yml .
At the time of writing:
stemcells: - alias: default os: ubuntu-trusty version: "3421.11"
Using bosh interpolate we can extract the stemcell version and upload it:
export STEMCELL_VERSION=$(bosh int ~/workspace/cf-deployment/cf-deployment.yml --path /stemcells/alias=default/version) bosh upload-stemcell https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-trusty-go_agent?v=$STEMCELL_VERSION
We are using newer cloud config model, which allows the separation of IaaS specific configuration from the deployment manifest.
bosh update-cloud-config ~/workspace/cf-deployment/iaas-support/bosh-lite/cloud-config.yml
The last step is to create and deploy our cloud foundry release. This may take long time, mostly depending on your internet connection.
bosh -d cf deploy ~/workspace/cf-deployment/cf-deployment.yml -o ~/workspace/cf-deployment/operations/bosh-lite.yml --vars-store ~/deployments/vbox/deployment-vars.yml -v system_domain=bosh-lite.com
To speed up deployment you can use precompiled releases by adding following operations file:
If nothing failed, you have successfully deployed Cloud Foundry! Yey!
The last step is to create a local route, to be able to access the Cloud Foundry Environment from your host.
sudo route add -net 10.244.0.0/16 gw 192.168.50.6
sudo route add -net 10.244.0.0/16 192.168.50.6
Configure Cloud Foundry
First we need to log-in into cloud foundry. The default username is admin and the password can be found in the deployment-vars.yml , which was generated by bosh deploy in the previous steps.
The following command will log you in and read the password from the file.
cf login -a https://api.bosh-lite.com --skip-ssl-validation -u admin -p $(bosh interpolate ~/deployments/vbox/deployment-vars.yml --path /cf_admin_password)
Lastly we have to create an organization and a space:
cf create-org cloudfoundry cf target -o cloudfoundry cf create-space development cf target -o cloudfoundry -s development
You are now ready to deploy your first app!
Deploy to Cloud Foundry
I’ve created a very simple python application which can be used for testing.
git clone https://github.com/vchrisb/cf-helloworld ~/workspace/cf-helloworld cd ~/workspace/cf-helloworld cf push
You should now be able to access the app locally via http://cf-helloworld.bosh-lite.com .
To try out Docker support, we first need to enable docker support and push a docker image.
cf enable-feature-flag diego_docker cf push test-app -o cloudfoundry/test-app
Please do not reboot or shutdown your BOSH Director VM, it won’t come up properly again!
To be able to save your state, you can can suspend and resume your BOHS Director with following commands:
vboxmanage controlvm $(bosh int ~/deployments/vbox/state.json --path /current_vm_cid) savestate vboxmanage startvm $(bosh int ~/deployments/vbox/state.json --path /current_vm_cid) --type headless
Your BOSH environment can be removed with following command:
bosh delete-env ~/workspace/bosh-deployment/bosh.yml \ --state ~/deployments/vbox/state.json \ -o ~/workspace/bosh-deployment/virtualbox/cpi.yml \ -o ~/workspace/bosh-deployment/virtualbox/outbound-network.yml \ -o ~/workspace/bosh-deployment/bosh-lite.yml \ -o ~/workspace/bosh-deployment/bosh-lite-runc.yml \ -o ~/workspace/bosh-deployment/jumpbox-user.yml \ --vars-store ~/deployments/vbox/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 rm ~/deployments/vbox/*
SSH into BOSH Director
If you would like to get a console on the BOSH Director, you can use following commands:
umask 077; touch ~/deployments/vbox/director_priv.key bosh int ~/deployments/vbox/creds.yml --path /jumpbox_ssh/private_key > ~/deployments/vbox/director_priv.key ssh email@example.com -i ~/deployments/vbox/director_priv.key
It is straight forward and easy to deploy Cloud Foundry with BOSH CLI v2 and cf-deployment to your localhost. The new cli greatly enhances the usability and deployment efforts.