Summary
Cloud Foundry is the premier platform as a service (PaaS). After using Cloud Foundry as a developer via IBM Bluemix and following some interesting tutorials on auto scaling, I wanted to try installing an instance of Cloud Foundry myself. Pivotal makes it pretty simple to do with these instructions Deploying Cloud Foundry but the information is on several pages and I made a few mistakes along the way and it took several hours. This tutorial is intended to be a step by step cookbook to deploy a Cloud Foundry App on your own to Cloud Foundry instance running on Amazon AWS.Note:
If you have to start over remove ~/.bosh_config. I don't think it gets updated. I was wondering my my setup was not working and it turned out this file was pointing to a system that no longer exists.
Create an AWS instance
This instance will be used to install the tools and code needed to create the Cloud Foundry instance. It will also contain the Cloud Foundry CLI tool, cf.- From Amazon EC2 Management, choose a Ubuntu Server.
- Select at least a medium server.
- By default, Amazon EC2 instances will not have enough space on the main file system so be sure to configure all instance details rather than just clicking Launch.
- Continue to Storage.
- Add 15 GiB of storage to the first device.
Install Bosh Lite
Login to Amazon EC2 virtual server.
Switch to root.
- sudo su -
Install these need prerequisites and then bosh_cli:
- apt-get update
- apt-get install -y build-essential ruby ruby-dev libxml2-dev libsqlite3-dev libxslt1-dev libpq-dev libmysqlclient-dev
- gem install bosh_cli.
- Note: You experience an error during document creation phase. Don't worry about that.
- apt-get -y install git
- mkdir ~/workspace
- cd ~/workspace
- git clone https://github.com/cloudfoundry/bosh-lite
Create an AWS security group
- Create an AWS security group called for example: CF_SecurityGroup in the default VPC.
- Add the following ports as inbound ports: 4443, 22, 80, 25555, 443 as shown in the picture below. Ch
Install Vagrant
Use Vagrant 1.6.3 (the "Known working version"). I thought this was a testing statement but it seems like 1.6.4 currently causes issues.
- cd /tmp
- wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.3_x86_64.deb
- dpkg -i ./vagrant_1.6.3_x86_64.deb
-
Install Vagrant AWS provider
- vagrant plugin install vagrant-aws --plugin-version 0.4.1
Set the following variables into the environment:
export BOSH_AWS_ACCESS_KEY_ID=<AWS access key id>
export BOSH_AWS_SECRET_ACCESS_KEY=<AWS secret access key>
export BOSH_LITE_KEYPAIR=<your AWS key name>
export BOSH_LITE_NAME=Vagrant
export BOSH_LITE_SECURITY_GROUP=CF_SecurityGroup
export BOSH_LITE_PRIVATE_KEY=<path to AWS private key>
For Example:
export BOSH_AWS_ACCESS_KEY_ID=AKIAI5SJGW...
export BOSH_AWS_SECRET_ACCESS_KEY=5dgGCXU/Q2C...
export BOSH_LITE_KEYPAIR=MyAmazonKeyPair
export BOSH_LITE_NAME=Vagrant
export BOSH_LITE_SECURITY_GROUP=CF_SecurityGroup
export BOSH_LITE_PRIVATE_KEY=~/myEC2Key.pem
- Copy your Amazon private key to this Ubuntu system.
- Key must be owned by user running Vagrant so make sure it is owned by root.
- chown root <path to AWS private key>
- chgrp root <path to AWS private key>
Run Vagrant
- cd ~/workspace/bosh-lite
- vagrant up --provider=aws
Note: If vagrant hangs at Waiting for SSH to become available... retry vagrant up with the --debug option.
Login to Bosh Director Lite
When Vagrant finishes, you will see output like this:
==> default: The public IP for this instance is 52.7.237.251
==> default: You can 'bosh target 52.7.237.251', or run 'vagrant ssh' and then 'bosh target 127.0.0.1'
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Setting up port forwarding for the CF Cloud Controller...
- bosh target <IP address of newly created EC2 instance, 52.7.237.251 in example above>
- You will be prompted for a username and password
- bosh user: admin
- bosh password: admin
Deploy Cloud Foundry
- cd ~/workspace
- Edit bosh-lite/manifests/cf-stub-spiff.yml to add a domain attribute.
- vi bosh-lite/manifests/cf-stub-spiff.yml
- add domain: <IP address of newly created EC2 instance, 52.7.237.251 in example above>.xip.io under properties section.
name: cf-warden
director_uuid: PLACEHOLDER-DIRECTOR-UUID
releases:
- name: cf
version: latest
properties:
loggregator_endpoint:
shared_secret: PLACEHOLDER-LOGGREGATOR-SECRET
domain: 52.7.237.251.xip.io
- Download Spiff from https://github.com/cloudfoundry-incubator/spiff/releases
- Install the latest binary spiff_linux_amd64.zip version.
- Add spiff in your PATH by com
- cd ~/workspace
- git clone https://github.com/cloudfoundry/cf-release
- cd bosh-lite
- bin/provision_cf
Setup Deployment
- Download Cloud Foundry CLI from https://github.com/cloudfoundry/cli/releases. Choose the Debian 64-bit version.
- cf api --skip-ssl-validation https://api.<new ip address>.xip.io
- eg.
cf api --skip-ssl-validation https://api.52.7.237.257.xip.io
cf login
Email: admin password: admin
cf create-org MyOrg
cf target -o MyOrg
cf create-space development
cf target -s development
Deploy Cloud Foundry
cd ~/workspace
git clone https://github.com/jbd214/cloudFoundryPythonApp.git
- cd cloudFoundryPythonApp
- cf push
Results of cf push
Python Cloud Foundry App running in browser
Valuable post useful for everyone.Keep on sharing.
ReplyDeletePivotal Cloud Foundry
Thanks for sharing your valuable information and time.
ReplyDeleteCloud Foundry Developer Online Training in Hyderabad
Cloud Foundry Online Training
Best Cloud Foundry Training Institute