PCF Dev is a distribution of Cloud Foundry that has a minimal footprint and is designed to run locally on a developer’s machine. Using this lightweight distribution of Cloud Foundry, a developer can debug and deploy applications locally.
In this article, we’ll go through the installation of PCF Dev on an Ubuntu development host.
First, you need at least 8Gb of system memory (with 16Gb recommended), and a minimum of 28Gb of disk (7Gb downloaded ova + 21Gb instantiated VM) plus the amount needed for each deployed app/service.
Then there are two component prerequisites, the CloudFoundry CLI tool and VirtualBox 5.0 or better.
Install CF CLI
Install the CF CLI which is a console based client application that communicates with the CF Cloud Controller.
$ wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - $ echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list $ sudo apt-get update $ sudo apt-get install cf-cli
Verify the CLI version, which should look similar to below:
$ cf --version cf version 6.31.0+b35df905d.2017-09-15
See my article on installing VirtualBox on Ubuntu.
Install PCF Dev
With the prerequisites complete, now install the PCF Dev plugin available from Pivotal at https://network.pivotal.io/products/pcfdev.
You will need a Pivotal account (which is free), and once signed up you can download the the Linux Version to your Ubuntu desktop (pcfdev-<VERSION>-linux.zip) and then run the install as a normal user.
$ unzip pcfdev-v0.28.0+PCF1.11.0-linux.zip $ ./pcfdev-v0.28.0+PCF1.11.0-linux Plugin successfully installed. Current version: 0.28.0. For more info run: cf dev help
Plugins get installed into $CF_HOME/.cf/plugins, which by default is $HOME/.cf/plugins. Verify all your currently installed plugins:
$ cf plugins Listing installed plugins... plugin version command name command help pcfdev 0.28.0 dev, pcfdev Control PCF Dev VMs running on your workstation
With the plugin now installed, you need to download and start the VM using ‘cf dev start’. The instantiated VM by itself requires 20+Gb space, so if your $HOME directory does not have enough storage capacity, you should set the $PCFDEV_HOME environment variable explicitly (e.g. “export PCFDEV_HOME=/data/.pcfdev”).
When prompted, use the Pivotal credentials created earlier.
$ cf dev start Please sign in with your Pivotal Network account. Need an account? Join Pivotal Network: https://network.pivotal.io Email> email@example.com Password> Downloading VM... Progress: |+++=================>| 100% VM downloaded. Allocating 4096 MB out of 32046 MB total system memory (28405 MB free). Importing VM... Starting VM... Provisioning VM... Waiting for services to start... 7 out of 58 running 7 out of 58 running 7 out of 58 running 7 out of 58 running 40 out of 58 running 56 out of 58 running 58 out of 58 running _______ _______ _______ ______ _______ __ __ | || || | | | | || | | | | _ || || ___| | _ || ___|| |_| | | |_| || || |___ | | | || |___ | | | ___|| _|| ___| | |_| || ___|| | | | | |_ | | | || |___ | | |___| |_______||___| |______| |_______| |___| is now running. To begin using PCF Dev, please run: cf login -a https://api.local.pcfdev.io --skip-ssl-validation Apps Manager URL: https://apps.local.pcfdev.io Admin user => Email: admin / Password: admin Regular user => Email: user / Password: pass
Then attempt to login to CF using the admin/admin credentials and selecting the pcfdev-org space:
$ cf login -a https://api.local.pcfdev.io -o pcfdev-org --skip-ssl-validation API endpoint: https://api.local.pcfdev.io Email> admin Password> Authenticating... OK Targeted org pcfdev-org Targeted space pcfdev-space API endpoint: https://api.local.pcfdev.io (API version: 2.82.0) User: admin Org: pcfdev-org Space: pcfdev-space
You now have a local PCF Dev environment. I would suggest you go through my article on deploying spring-music as your first CF application to test your deployment (be sure the API endpoint is set to ‘api.local.pcfdev.io’).
After you push the deployment, you should be able to pull up a browser view similar to the one below (but the URL will be https://spring-music-<word1>-<word2>.local.pcfdev.io).
Offline DNS resolution of local.pcfdev.io
The reason our browser can hit the API and applications at “*.local.pcfdev.io” is because of a little trick where a publicly available wildard DNS record for local.pcfdev.io always resolves to the IP address 192.168.11.11. And the local PCF Dev VM is hardcoded to the IP address 192.168.11.11 by leveraging a host-only network.
But if you are doing local development, you might not be connected to a network. You might be traveling on a plane, or at a customer site giving a demonstration.
This can be worked around by installing a local DNS server, on Ubuntu we can use dnsmasq.
$ sudo apt-get install dnsmasq $ echo "address=/.local.pcfdev.io/192.168.11.11" | sudo tee /etc/dnsmasq.conf $ sudo service dnsmasq restart $ sudo netstat -plant | grep :53
Now if you modify “/etc/resolv.conf” so that it uses the local DNS server:
Then when you do an nslookup, you will see that resolution against the local 127.0.0.1 server returns back an IP address of “192.168.11.11”, which is the hard coded IP address of PCF Dev.
$ nslookup test.local.pcfdev.io Server: 127.0.0.1 Address: 127.0.0.1#53 Name: test.local.pcfdev.io Address: 192.168.11.11
http://cli.cloudfoundry.org/en-US/cf/ (cf command reference)
https://docs.cloudfoundry.org/cf-cli/use-cli-plugins.html (default install locations)
https://docs.pivotal.io/pcf-dev/work-offline.html (dnsmasq for offline DNS resolution of *.local.pcfdev.io)
https://help.ubuntu.com/community/Dnsmasq (dnsmasq reference)
https://docs.pivotal.io/pcf-dev/proxy.html (behind proxy)
https://stackoverflow.com/questions/36596743/how-to-install-cloudfoundry-on-local-server (both-lite is another way for local development)
http://docs.cloudfoundry.org/deploying/boshlite/ (BOSH-lite and CF)
http://docs.stackato.com/admin/setup/microcloud.html (Micro Cloud VM from HPE is another way for local development)
SSH login to PCF Dev is user/pass: vcap/vcap
cf dev –help (start,stop,destroy,version)
nmap -A -T4 192.168.11.11 (scan PCF Dev for open ports)
If you get “getsockopt: connection refused” when trying to connect and can’t get a connection using telnet to 192.168.11.11:443, then the problem might be the VirtualBox host-only networking. Check the network connections of the VM, the first adapter will be NAT, the second should be a host-only network with the specification 192.168.11.1. Also, I noticed that if you already have multiple host-only networks, this can be an issue.
$ vboxmanage list hostonlyifs | grep "^Name:"
I had success when I had only one vboxnet0 network, and PCF dev created and used vboxnet1 at 192.168.11.11. But I had issues when I already had vboxnet0 and vboxnet1, and PCF Dev was created vboxnet2. I had to delete two of the host-only networks, then “cf dev delete”; then completely deploy again with “cf dev start” to get proper network connectivity.