We’re investigating Cloud Foundry for our PAAS solution. At home I’ve installed it on my mac with virtualbox. This post is a combination of information available elsewhere (links are included) and can be used to get you’re own local Cloud Foundry up and running.
Prerequisites
Install VirtualBox (https://www.virtualbox.org/wiki/Download_Old_Builds_5_2)
Install VirtualBox extension pack
Install xcode
xcode-select --install
Install Homebrew (https://brew.sh) and use it to install bosh-cli, openssl and node.js
brew install cloudfoundry/tap/bosh-cli brew install openssl brew install node
Now start installation …
Bosh-lite
Follow https://bosh.io/docs/bosh-lite/ and you’ll have bosh-lite running. JUST DON’T INSTALL ZOOKEEPER! The script I’ve used is below. The last line adds a route to the system that is crucial for the cloud foundry cli to work.
git clone https://github.com/cloudfoundry/bosh-deployment ~/workspace/bosh-deployment mkdir -p ~/deployments/vbox cd ~/deployments/vbox bosh create-env ~/workspace/bosh-deployment/bosh.yml \ --state ./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/uaa.yml \ -o ~/workspace/bosh-deployment/credhub.yml \ -o ~/workspace/bosh-deployment/jumpbox-user.yml \ --vars-store ./creds.yml \ -v director_name=bosh-lite \ -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 bosh alias-env vbox -e 192.168.50.6 --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca) export BOSH_CLIENT=admin export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password` sudo route add -net 10.244.0.0/16 192.168.50.6 # Mac OS X
Congratulations you’ve now got a working bosh-lite installation. You can use the bosh-cli to interact with it. Now install/deploy Cloud Foundry.
Cloud Foundry
Read up on http://operator-workshop.cloudfoundry.org/labs/deploy-cf/ but use the script below as it fills some holes.
git clone https://github.com/cloudfoundry/cf-deployment ~/workspace/cf-deployment cd ~/workspace/cf-deployment git checkout tags/v1.15.0 export BOSH_ENVIRONMENT=192.168.50.6 bosh update-cloud-config ~/workspace/cf-deployment/iaas-support/bosh-lite/cloud-config.yml export STEMCELL_VERSION=$(bosh int 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" export SYSTEM_DOMAIN=bosh-lite.com bosh -d cf deploy ~/workspace/cf-deployment/cf-deployment.yml \ -o ~/workspace/cf-deployment/operations/bosh-lite.yml \ -o ~/workspace/cf-deployment/operations/use-compiled-releases.yml \ --vars-store deployment-vars.yml \ -v system_domain=$SYSTEM_DOMAIN
Now login to you’re Cloud Foundry environment. The password for the admin user is revealed with the first statement of the script below.
More info on (http://operator-workshop.cloudfoundry.org/labs/cf-basics/):
bosh interpolate --path /cf_admin_password ~/workspace/cf-deployment/deployment-vars.yml cf login -a https://api.$SYSTEM_DOMAIN --skip-ssl-validation cf create-org demo cf target -o demo cf create-space dev cf target -o demo -s dev
Stratos
A nice GUI for your Cloud Foundry is Stratos. You deploy Stratos to CF with details from https://github.com/cloudfoundry-incubator/stratos/tree/v2-master/deploy/cloud-foundry This is where node.js is needed.
cd ~/workspace git clone https://github.com/cloudfoundry-incubator/stratos cd stratos git checkout tags/stable -b stable npm install npm run prebuild-ui cf push
Now logon to Stratos on https://console.bosh-lite.com with Admin and the password from the first line in the previous script.
Save state the VirtualBox machine before shutdown to preserve your environment. After a restart create the route again.
Extra
If you’ve already installed node, make sure to update it to the latest version:
brew update brew upgrade node npm update -g npm
Pingback: Deploy your first dotnet core app to Cloud Foundry | .NET Development by Eric
This is a really nice and detailed recipe. Unfortunately I hit a snag during the cloud-foundry deployment:
…
Creating disk… Finished (00:00:00)
Attaching disk ‘disk-e1e46319-da4c-4d3c-6788-3f2bc3844b7e’ to VM ‘vm-c27e40b8-464c-4922-7078-03a2900425eb’… Failed (00:01:12)
Failed deploying (00:01:48)
Cleaning up rendered CPI jobs… Finished (00:00:00)
Deploying:
Creating instance ‘bosh/0’:
Updating instance disks:
Updating disks:
Deploying disk:
Mounting disk:
Sending ‘get_task’ to the agent:
Agent responded with error: Action Failed get_task: Task c0345d0d-6411-46d2-48a6-433882eed5fb result: Mounting persistent disk: Getting real device path: Timed out getting real device path for ‘1ATA’
Exit code 1
Any hints gratefully accepted. I am investigating, but there could be any number of reasons why it didn’t work, including my adapting the various directory paths shown in the recipe. So, being a relative newbie to CF, I expect it will be difficult to isolate the cause.
Sorry, my mistake – this error arose during the bosh create-env command.
How did you solve this?
May be related to this issue: https://github.com/cloudfoundry/bosh-deployment/issues/378
It works when you downgrade / upgrade Virtualbox to 6.0.14 – the last version available in Homebrew before 6.1. There’s 6.0.22 available if you are maintaining your Virtualbox installation manually.
“`
brew cask uninstall virtualbox virtualbox-extension-pack
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
git -C . fetch –unshallow
git checkout 7e703e0466a463fe26ab4e253e28baa9c20d5f36
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install \
virtualbox virtualbox-extension-pack
git checkout HEAD
“`
Sometimes all you need is specific version – good to hear you’ve got it running.