The Cloud Foundry Bootcamp document provides an overview of a Cloud Foundry bootcamp presented in Portland in 2012. It was written by Chris Richardson and presented by Monica Wilkinson and Josh Long. The agenda covers why Platform as a Service (PaaS) matters to developers, an overview of Cloud Foundry, getting started with Cloud Foundry, the Cloud Foundry architecture, using Micro Cloud Foundry, and consuming Cloud Foundry services.
2. About Monica Wilkinson Loves the web and data portability.
Developer Advocate @ Cloud Foundry
12 years development experience.
Last 5 years in Social Web
Open Web Standards Advocate
@ciberch
mwilkinson@vmware.com
CONFIDENTIAL
2
3. About Josh Long
Spring Developer Advocate
@starbuxman
josh.long@springsource.com
th
si
is
im
po
rta
nt
!
Free Book!
SpringSource.org/roo
CONFIDENTIAL
3
5. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud
Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry
services
5
6. Traditional web application architecture
Web Application
StoreFront
Accounting
Service
MySQL
Desktop Database
Apache
Browser InventoryService
Shipping
Service
Simple to Container (e.g. Tomcat)
develop
test
deploy
scale
6
7. Traditional web application architecture
Web Application
StoreFront
Accounting
Service
MySQL
Desktop Database
Apache
Browser InventoryService
Shipping
Service
Simple to Container (e.g. Tomcat)
develop
test
deploy
scale Or is it? 6
8. Let’s imagine you want to run a
performance test...
?
How long to get the servers?
Who is going to set up the servers?
Who is going to set up Apache,
Tomcat, and MySQL?
9. And things are changing:
This simple, monolithic architecture is
inadequate
8
10. New kinds of clients
Smart phones overtake PCs in Q4 2010
9
11. Users expect a rich, dynamic and interactive experience on mobile
devices and desktop
HTTP Request
Desktop
Web Application
Browser HTML/Javascript
10
12. Users expect a rich, dynamic and interactive experience on mobile
devices and desktop
h
oug
d en
oo
’t g
HTTP Request
e isn
r
ctu
Desktop
Web Application
e
hit
Browser HTML/Javascript
I arc
ty le U
s
Old
10
13. Need to handle massive loads and the data explosion
Need scalable architectures
Application tier:
• Replicated/clustered servers
• Modular so that components can be scaled differently
• Asynchronous architecture - communication via a message
broker
Database tier:
• Replication
• Sharding
• Polyglot persistence: Relational, NoSQL, NewSQL
databases
11
14. Scaling development
Web application
StoreFront
Accounting
Service Scalable
!=
InventoryService development
Shipping
Service
Strongly coupled components makes development difficult
Forces multiple developers/teams to synchronize development efforts
Obstacle to frequent, independent deployments
Increases risk of failure - need to redeploy everything to change one thing 12
15. Modern application architecture
billing web application
Desktop Accounting
Browser Service
StoreUI
Native Mobile NodeJS
NodeJS inventory web application
Application front-end
MySQL
application
StoreUI
StoreUI InventoryService
HTML5 mobile
application
StoreUI Redis shipping web application
RabbitMQ
Mongo
ShippingService
13
17. Let’s imagine you are fixing a bug
and want to run some JUnit
integration tests...
?
Who is going to setup your sandbox:
MySQL, RabbitMQ, MongoDB, ....?
18. Let’s imagine you have fixed a bug
and want to run some functional
tests...
?
How long to purchase the servers?
Who is going to set up the servers?
Who is going to setup MySQL,
RabbitMQ, MongoDB, ....?
19. Platform-as-a-Service is the solution
Deployment Services
Easy deployment SQL databases
Application management + NoSQL databases
Easy scaling up and down Message Broker
17
20. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud
Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry
services
18
21. The Open
Platform as a Service
Deploy and scale applications in
seconds, without locking yourself
p en,
e, O lable
Simpl Sca
Flex ible,
19
24. Cloud Foundry open PaaS - Choice of application services
Ap
p lic
Data
at
Services
io
n
Se
r
vic
e
In
te
Msg
rfa
Services
ce
Other
Services
25. Cloud Foundry open PaaS - Choice of application services
vFabric
Postgres
Ap
p lic
Data
at
Services
io
n
Se
r
vic
vFabric
e
In
te
RabbitMQTM Msg
rfa
Services
ce
Other
Services
Additional partners
services …
26. Cloud Foundry open PaaS - Choice of clouds
Ap
p
Private
lic
Data
at
Services Clouds
io
n
Se
ce
r
vic
rfa
e
te
In
In
te
Public
er
Msg
rfa
vid
Services Clouds
ce
o
Pr
ud
o
Cl
Micro
Other Clouds
Services
27. Cloud Foundry open PaaS - Choice of clouds
d
Avoi n
Ap
p Lo ck-i
Private
lic
Data
at
Services Clouds
io
n
Se
ce
r
vic
rfa
e
te
In
In
te
Public
er
Msg
rfa
vid
Services Clouds
ce
o
Pr
ud
o
Cl
Micro
Other Clouds
Services
29. Multi-cloud flexibility is critical to your long-term success
Make use of both public and private clouds without rewriting your
applications
23
30. Multi-cloud flexibility is critical to your long-term success
Make use of both public and private clouds without rewriting your
applications
Protect against vendor lock-in
23
31. Multi-cloud flexibility is critical to your long-term success
Make use of both public and private clouds without rewriting your
applications
Protect against vendor lock-in
Meet different compliance and geographical needs
23
32. Multi-cloud flexibility is critical to your long-term success
Make use of both public and private clouds without rewriting your
applications
Protect against vendor lock-in
Meet different compliance and geographical needs
Accommodate peak loads while optimizing costs
23
33. Multi-cloud flexibility is critical to your long-term success
Make use of both public and private clouds without rewriting your
applications
Protect against vendor lock-in
Meet different compliance and geographical needs
Accommodate peak loads while optimizing costs
Manage your growth and changing needs over time
23
35. Micro Cloud FoundryTM – Industry first downloadable PaaS
Micro Cloud Foundry
Runtimes & Frameworks
Services
Your Laptop/PC
Single VM instance of
Cloud Foundry
that runs on a developer’s
MAC or PC
25
37. Cloud Foundry: you can trade-off effort vs flexibility
Less
Less
Public PaaS
....
.COM
Private PaaS
Effort .... Flexibility
Custom Private PaaS
git clone git://github.com/cloudfoundry/
More More
27
38. Cloud Foundry Resources
Primary Site : cloudfoundry.com
Open Source Site : cloudfoundry.org
Twitter : @cloudfoundry
Blog : blog.cloudfoundry.com
FB : facebook.com/cloudfoundry
Documentation: start.cloudfoundry.com
Support : support.cloudfoundry.com
• Knowledge Base
• Q & A / Forums
28
39. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud
Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry
services
29
50. Installing vmc on Mac OSX
Use Ruby Version Manager http://beginrescueend.com/
$ bash -s stable
<<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
34
51. Installing vmc on Mac OSX
Use Ruby Version Manager http://beginrescueend.com/
$ bash -s stable
<<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
$ rvm install 1.9.2
$ rvm use 1.9.2
34
52. Installing vmc on Mac OSX
Use Ruby Version Manager http://beginrescueend.com/
$ bash -s stable
<<(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
$ rvm install 1.9.2
$ rvm use 1.9.2
$ gem install vmc
34
63. Recap so far…
Understand PaaS
Register for Cloud Foundry
Installed the Cloud Foundry Plugin
Logged In/Authenticated
Create a Spring MVC App
Deployed MVC App to Cloud Foundry
Hit URL from STS and Viewed MVC App
Learned about vmc
45
64. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud
Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry
services
46
65. Cloud Foundry - Architecture
Message Bus
Message Bus
Web
Web Message Bus
(NATS)
(NATS)
(NATS)
100’s of DEAs
App
Load Balancers
Load Balancers
App Load Balancers
App
DEAs
DEAs
DEAs
Routers
Routers
Routers
Cloud
Cloud
Controllers
Cloud
Controllers
DB Controllers
DB
DB
Web Service API
Services Health
Health
Services Health
Manager
Services Manager
Manager
Client, e.g.VMC
71. Application deployment flow
find DEA for
app
vmc push
create app
VMC Cloud Controller DEA
DEA Application
Framework
detection
Framework
specific
staging plugin
Creates
Droplet
Router
Router
48
72. Application deployment flow
find DEA for
app
vmc push I’m available
create app
VMC Cloud Controller DEA
DEA Application
Framework
detection
Framework
specific
staging plugin
Creates
Droplet
Router
Router
48
73. Application deployment flow
find DEA for
app
vmc push I’m available
create app
VMC Cloud Controller DEA
DEA Application
deploy droplet
Framework
detection
Framework
specific
staging plugin
Creates
Droplet
Router
Router
48
74. Application deployment flow
find DEA for
app
vmc push I’m available
create app
VMC Cloud Controller start
DEA
DEA Application
deploy droplet
Framework
detection
Framework
specific
staging plugin
Creates
Droplet
Router
Router
48
75. Application deployment flow
find DEA for
app
vmc push I’m available
create app
VMC Cloud Controller start
DEA
DEA Application
deploy droplet
Framework
detection
Framework
specific
staging plugin
update routes
Creates
Droplet
Router
Router
48
76. About the staging plugin
Framework specific
Creates a zip file = black box
• Contains everything necessary for DEA to run the application
• Two scripts: start.sh, stop.sh
49
77. Staging plugin for the Spring framework
Adds CloudAutoStagingBeanFactoryPostProcessor bean:
• Modifies bean definitions
• Implements auto-reconfiguration
Defines CloudApplicationContextInitializer in web.xml
• Activates cloud profile
• Defines PropertySource for CloudEnvironment properties
50
78. VCAP_APPLICATION environment variable
{
"instance_id": "598f4af3b49ed5fc9bd19bef67650f61",
"instance_index": 0,
"name": "myapplication",
"uris": ["myapp.cloudfoundry.com"],
"users": ["crichardson@vmware.com"],
"version": "6126ec0a1ea366c61635398f1d2824086e40aec4-1",
"start": "2012-02-24 06:39:17 +0000",
"runtime": "node",
"state_timestamp": 1330065557,
"port": 21059,
"limits": {
Tells your application about
"fds": 256, where it is running
"mem": 67108864,
"disk": 2147483648
},
"host": "172.30.50.10"
}
String value = System.getenv("VCAP_APPLICATION")
51
79. Custom Application environment variables
$ vmc env-add cf1 PAYMENT_SVC=http://...
Adding Environment Variable
[PAYMENT_SVC=http://...]: OK
Stopping Application: OK
Staging Application: OK
Starting Application: OK
String value = System.getenv("PAYMENT_SVC")
@Value("#{systemEnvironment['PAYMENT_SVC']}")
private String envVariable;
84. Self Healing Infrastructure
If an application instance crashes
• DEA detects unexpected exit => DEA broadcasts message
• Routers remove instance from routing
• Health manager notifies Cloud Controller
• Cloud Controller re-launches instance
If an DEA VM crashes
• Application instances become unavailable
• Health Manager notices the missing instances and notifies the
Cloud Controller
• Cloud Controller requests application instances to be started
• Existing DEA will reply and start the applications
85. But where are the VMs?!?
Cloud Foundry has a layered architecture
• Cloud Controller, DEA, … layer = processes
• VM management layer
Benefits: decoupling, simplicity, ….
CloudFoundry.com creates vSphere VMs running different Cloud Foundry
components
86. Recap
DEAs
Service Gateways
NATS
Cloud Controllers
Routing/Load Balancing
Health Manager
56
87. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry services
57
88. What is in Micro Cloud Foundry?
App Instances Services
Open source Platform as a Service project
10.04
A cloud packaged as a VMware Virtual Machine
Use as a developer sandbox
• Use the services from Junit integration tests
• Deploy your application for functional testing
• Remote debugging from STS
58
89. Pre-requisites for using Micro Cloud Foundry
Minimum 1 GB Minimum 8 GB Internet Connectivity
RAM Disk (w/DHCP is ideal)
VMC STS
Command line GUI
59
103. Deploy an application in the usual way
$ vmc push --path target
Application Name: DemoWebapp
Application Deployed URL [DemoWebapp.cer-micro1.cloudfoundry.me]:
Detected a Java Web Application, is this correct? [Yn]:
Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
Creating Application: OK
Would you like to bind any services to 'DemoWebapp'? [yN]:
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (3K): OK
Push Status: OK
Staging Application: OK
Starting Application: OK
68
104. Deploy an application in the usual way
$ vmc push --path target
Application Name: DemoWebapp
Application Deployed URL [DemoWebapp.cer-micro1.cloudfoundry.me]:
Detected a Java Web Application, is this correct? [Yn]:
Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
Creating Application: OK
Would you like to bind any services to 'DemoWebapp'? [yN]:
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (3K): OK
Push Status: OK
Staging Application: OK
Starting Application: OK
$ curl DemoWebapp.cer-micro1.cloudfoundry.me
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
Chriss-MacBook-Pro:demowebapp cer$
68
105. Offline Micro Cloud Foundry
The problem:
• Cloud Foundry accessed via hostname, which is pretty cool
• Hostname resolved by DNS server ==> laptop needs to be online
The solution:
• Micro Cloud Foundry now supports true offline mode
• New command:vmc micro
• Reconfigures DNS on your machine to resolve *.cloudfoundry.me locally
• Requires: vmc 0.3.16.beta4 or higher, on Mac VMware Fusion 4.x
69
106. Offline Micro Cloud Foundry: vmc micro status
saved in ~/.vmc_micro
$ vmc micro --vmx /MyVirtualMachines/micro.vmx
--vmrun /Applications/VMware Fusion.app/Contents/Library/vmrun status
Please enter your Micro Cloud Foundry VM password (vcap user) password: ********
Micro Cloud Foundry VM is not running. Do you want to start it? (y, n): y
Starting Micro Cloud Foundry VM: done
Micro Cloud Foundry VM currently in online mode
VMX Path: /Users/cer/Downloads/microCloudFoundry/micro/micro.vmx
Domain: cer-micro1.cloudfoundry.me
IP Address: 192.168.253.128
70
108. Offline Micro Cloud Foundry: vmc micro offline/online
$ vmc micro offline
Please enter your Micro Cloud Foundry VM password (vcap user) password: ********
Setting Micro Cloud Foundry VM to offline mode: done
Setting host DNS server: done
Reconfigures DNS to use Micro Cloud Foundry as one of the DNS servers
Resolves cer-micro1.cloudfoundry.me to 192.168.253.128
71
109. Offline Micro Cloud Foundry: vmc micro offline/online
$ vmc micro offline
Please enter your Micro Cloud Foundry VM password (vcap user) password: ********
Setting Micro Cloud Foundry VM to offline mode: done
Setting host DNS server: done
Reconfigures DNS to use Micro Cloud Foundry as one of the DNS servers
Resolves cer-micro1.cloudfoundry.me to 192.168.253.128
$ vmc micro online
Please enter your Micro Cloud Foundry VM password (vcap user) password: ********
Unsetting host DNS server: done
Setting Micro Cloud Foundry VM to online mode: done
Undoes the change to DNS configuration
71
110. Recap…
Installed the Micro Cloud Foundry
Got a Token
Configured Micro Cloud Foundry
Registered
Logged In/Authenticated
Created a Spring MVC App
Deployed MVC App to Micro Cloud Foundry
Set a breakpoint, hit URL from STS and viewed MVC App
72
111. Agenda
Why PaaS matters to developers
Overview of Cloud Foundry
Getting started with Cloud Foundry
Cloud Foundry architecture
Using Micro Cloud Foundry
Consuming Cloud Foundry services
73
113. Creating a service instance
$ vmc create-service mysql --name mysql1
Creating Service: OK
$ vmc services
============== System Services ==============
+------------+---------+---------------------------------------+
| Service | Version | Description |
+------------+---------+---------------------------------------+
| mongodb | 1.8 | MongoDB NoSQL store |
| mysql | 5.1 | MySQL database service |
| postgresql | 9.0 | PostgreSQL database service (vFabric) |
| rabbitmq | 2.4 | RabbitMQ messaging service |
| redis | 2.2 | Redis key-value store service |
+------------+---------+---------------------------------------+
=========== Provisioned Services ============
+-------------+---------+
| Name | Service |
+-------------+---------+
| mysql1 | mysql |
+-------------+---------+
114. Binding a service to an application
$ vmc push cer-spring --path web/target/
Application Deployed URL [cer-spring.cloudfoundry.com]:
Detected a Java SpringSource Spring Application, is this correct? [Yn]:
Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
Creating Application: OK
Would you like to bind any services to 'cer-spring'? [yN]: y
Would you like to use an existing provisioned service? [yN]: y
The following provisioned services are available
1: mysql1
2: mysql-135e0
Please select one you wish to use: 1
Binding Service [mysql1]: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (12K): OK
115. Binding a service to an application
$ vmc push cer-spring --path web/target/
Application Deployed URL [cer-spring.cloudfoundry.com]:
Detected a Java SpringSource Spring Application, is this correct? [Yn]:
Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
Creating Application: OK
Would you like to bind any services to 'cer-spring'? [yN]: y [yN]: y
Would you like
to bind any services to 'cer-spring'?
Would you like to use anan existing provisioned service? [yN]: y
Would you like
to use existing provisioned service? [yN]: y
The The following provisioned servicesavailable
following provisioned services are are available
1: mysql1
1: mysql1
2: mysql-135e0
2: mysql-135e0
Please select one you wish to use:use: 1
Please select one you wish to 1
Binding Service [mysql1]: OK OK
Binding Service [mysql1]:
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (12K): OK
116. Binding a service to an application
$ vmc push cer-spring --path web/target/
Application Deployed URL [cer-spring.cloudfoundry.com]:
Detected a Java SpringSource Spring Application, is this correct? [Yn]:
Memory Reservation (64M, 128M, 256M, 512M, 1G) [512M]:
Creating Application: OK
Would you like to bind any services to 'cer-spring'? [yN]: y
Would you like to use an existing provisioned service? [yN]: y
The following provisioned services are available
1: mysql1
2: mysql-135e0
Please select one you wish to use: 1
Binding Service [mysql1]: OK
Uploading Application:
Checking for available resources: OK
Processing resources: OK
Packing application: OK
Uploading (12K): OK
117. Binding a service to an application
$ vmc bind-service mysql1 myapp
Binding Service [mysql1]: OK
Stopping Application 'myapp': OK
Staging Application 'myapp': OK
Starting Application 'myapp': OK
$
120. Uses MySQL and MongoDB
@Entity
public class Customer { Stored in MySQL
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String firstName;
private String lastName;
Stored in Mongo
@RelatedDocument
private SurveyInfo surveyInfo;
public class SurveyInfo { public class Survey {
private List<Survey> questionsAndAnswers = new ArrayList<Survey>(); String question;
public List<Survey> getQuestionsAndAnswers() { String answer;
return questionsAndAnswers;
}
80
138. .js
Ap
ce
Private
p
lic
Data
rfa
Services
Clouds
at
te
io
In
n
er
Se
vid
r
Public
vic
o
Clouds
e
Pr
Msg Services
In
ud
te
o
rfa
Cl
ce
Other
Micro
Services Clouds
Hello, thank you or having me. Im pleased to have the opportunity to introduce you today to Spring and the SpringSource Tool Suite \n\nMy name is Josh Long. I serve as the developer advocate for the Spring framework. I&#x2019;ve used it in earnest and advocated it for many years now. i&#x2019;m an author on 3 books on the technology, as well as a comitter to many of the Spring projects. Additionally, I take community activism very seriously and do my best to participate in the community. Sometimes this means answering question on Twitter, or in the forums, or helping contribute to the InfoQ.com and Artima.com communities\n
\n
I&#x2019;m first going to take a step back and talk about why I think PaaS matters to developers like us.\nI&#x2019;m then going to talk about various features of Cloud Foundry.\n
Almost all the applications that I&#x2019;ve developed over the past 10+ years have looked like this.\n\nEach application has consisted of a single WAR file\n
So let&#x2019;s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
And to make matters worse:\n technology trends are making this simplistic architecture inadequate\n
End users expect to access applications from their smart phones.\nIn fact, smart phones sales over took PC sales a year ago.\n
Users expect a rich, dynamic .. experience on mobile devices and browsers.\nSimply serving up HTML or HTML+JavaScript is no longer good enough.\n
Applications need to scale to support massive loads.\n
We also need to be able to scale development.\nWe need to have multiple development teams\nWe need to be able to frequently update production - perhaps many times a day.\n\nThe problem is that a monolithic WAR is an obstacle to doing that.\n\n
The end result is an architecture like this.\n\n
It was pretty easy to dev/test a WAR.\nThe challenge we have now is that ....\n\n\n
So let&#x2019;s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
So let&#x2019;s imagine that you fixing a bug or working on a feature and you want to run an integration test.\n\n
So what is PaaS?\n\nPaas gives you an easy way to deploy and manage your application.\nIn the Java world that means you basically upload your WAR file and the PaaS environment takes over from there.\n\nThe PaaS should also give you an easy way to scale your application up to deal with increased load; and scale your application down when the load drops.\n\nA PaaS environment should offer services such as databases, blob storage, messaging, etc.\n
\n
Cloud Foundry is an open-PaaS.\nYou can deploy and scale applications...\n
Cloud Foundry gives you a choice of frameworks and languages.\n
Cloud Foundry gives you a choice of services\n
Cloud Foundry gives you a choice of Clouds\nIt is available on public Clouds such as CF.com\nYou can run it in-house in a private Cloud.\nYou can also run it as a VM on your laptop.\nI&#x2019;ll talk more about these different types of CF.com in a moment.\n
The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
The suppose for multiple clouds is extremely important.\nIt means that you can run your application on public and private clouds without having to rewrite it.\n
There are three different ways of using Cloud Foundry.\n\nThe first is CloudFoundry.com, which is a \n
As well as the public cloud, there is MCF\nIt is a VM that you can run on your desktop or laptop.\nIt has the same frameworks and services that CloudFoundry.com has.\n\nThe micro cloud particularly useful to development and testing.\nIt is your own very private sandbox.\n
There is also CloudFoundry.org, the open source project.\nIt contains all the features of CloudFoundry.com along with many community contributions.\nYou can download the source code for Cloud Foundry from github.com and run it on your own in-house infrastructure.\n
so as you can see Cloud Foundry is all about choice.\nIt allows you to make very interesting tradeoffs between implementation effort and flexibility.\n\nYou can deploy your application on a public cloud - \nThat&#x2019;s extremely easy but you are constrained by choices that the public cloud offers.\n\nAlternatively, you can download the source from Cloud Foundry.\nExtend CF to support additional frameworks and services.\nRun it on your own in-house hardware.\nThis gives you tremendous flexibility but of course, potentially requires a lot of development effort.\n\nThere is also the middle ground, of running a private cloud paas product based on Cloud Foundry.\n\n
So that&#x2019;s Cloud Foundry in a nutshell.\nThere are a great many resources that can help you get started including those shown on this slide.\n
So I now want to walk you through the process of getting started with Cloud Foundry\n
The first step is to register at Cloud Foundry.com\n\nYou enter your email address along with a promo code to expedite signup\n
You will then get a welcome email containing your temporary password\n
Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
Once you have been signed up you can then start using CloudFoundry.com\n\nYou have several different tools to choose from.\n\nI want to begin by showing you the command line tool- vmc\n
Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
Vmc is written in Ruby so the first step is to install the Ruby runtime.\nOn Windows...\n
On Mac, you can use the Ruby Version Manager to install ruby.\n
On Mac, you can use the Ruby Version Manager to install ruby.\n
\n
After you have installed VMC, the next step is to login into CloudFoundry.com\n\nYou first execute the vmc target command to tell VMC which cloud you want to use.\n\nOnce you have done that you use the login command to enter your credentials.\n\nAfter logging into you are now ready to deploy your application\n
After you have installed VMC, the next step is to login into CloudFoundry.com\n\nYou first execute the vmc target command to tell VMC which cloud you want to use.\n\nOnce you have done that you use the login command to enter your credentials.\n\nAfter logging into you are now ready to deploy your application\n
I&#x2019;m now going to show you to deploy an application using Cloud Foundry.\nThis demo uses Java because that&#x2019;s the language I&#x2019;m most familiar with but you would use the exact same steps to deploy a Rails or NodeJS application, for example.\n
I&#x2019;m now going to show you to deploy an application using Cloud Foundry.\nThis demo uses Java because that&#x2019;s the language I&#x2019;m most familiar with but you would use the exact same steps to deploy a Rails or NodeJS application, for example.\n
\n
\n
This is what happens when you run the command.\n
This is what happens when you run the command.\n
This is what happens when you run the command.\n
This is what happens when you run the command.\n
\n
As well as deploying your application, vmc push can also create a manifest file.\nThis captures the information you entered about your application and eliminates the need for you to re-enter it.\n\nas you can see, this file specifies the target directory, the application name, url etc.\n\n\n\n
Once you have deployed the application there are various commands that you can use.\n\nFor example, you can scale the application using the vmc scale command.\n\nIn this example, I&#x2019;m added two more instances of the application.\n\n\n
You can also use Cloud foundry from within STS, which is an eclipse-based IDE for building enterprise java applications.\n
The\n
\n
\n
1. Create template app\n2. Had to explicitly enable maven dependency management\n3. Drag and drop to CF\n4. Can open home page\n5. Modifying application required &#x201C;Updated and restart&#x201D;\n6. Takes a while to redeploy and update the home page (no surprise really)\n
\n
\n
I now want to spend a few minutes talking about the Cloud Foundry architecture\n
This slide shows the Cloud Foundry architecture.\n\nThe CC exposes the WS API that the VMC CLI uses to manage applications and services. There are typically a few CC instances to handle the load and provide failover.\n\nThe DEAs are responsible for running and monitoring applications.\nA DEA typically runs on a VM and manages some number of application instances.\nThere are typically 100s of them.\n\nThere are routers that proxy HTTP requests to application instances.\nHandles load balancing etc.\n\nThere is also the health manager that monitors the state of the world and takes action when reality doesn't match expectations.\n\nAl these components are loosely coupled and communicate asynchronously through a message bus.\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
VMC \n Detects framework\n Creates zip containing what's not been previously uploaded\n Cloud Controller\n Runs staging plugin to create Droplet\n Broadcasts for a suitable DEA\n DEAs announce availability\n Cloud Controller \n Selects DEA (first responder)\n Sends droplet to DEA\n DEA:\n Unzips droplet\n Runs start script\n Tells routers to proxy URL to instance\n Routers\n Update routing tables\n Proxy HTTP requests to application instances\n
The packaging of the application into a droplet is handled by a framework-specific staging plugin.\n\nIt creates a zip file that contains everything the DEA needs to run the application.\nAt its root at two scripts: start and stop that are invoked by the DEA.\n
What the staging plugin does is very dependent on the framework.\nFor example, the Spring staging plugin alters the application&#x2019;s configuration.\n\n\n\n
I&#x2019;m going to talk about this more later but I wanted to mention it here.\nWhen Cloud Foundry runs your application, it sets certain environment variables including VCAP_APP.\nThis env var is an JSON document that contains information that the application needs.\nFor example, the application can look at this env var to determine its URL.\nThe framework runtime can look at this env var to determine what port it should run on.\n\n#MOVED\n
You can also define your own custom environment variables in order to configure your application.\nYou use the env-add command to set an environment variable.\nThe application that then access that ENV var using some language/framework specific mechanism.\n\n#MOVED\n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Load balancer\n Sends request to one of many Routers\n Router\n Selects application instance\n Handles sticky sessions\n Forwards request to application instance\n Application instance\n Handles request\n \n
Die when you are dead\n
In all of this discussion you might be wondering where the VMs are?\n
\n
I now want to talk Micro Cloud Foundry, which is a version of CF that you can download and run on your desktop or laptop.\n
MCF is CF packaged as a VMware virtual machine.\nIt contains all the services as CloudFoundry.com\n\nIt&#x2019;s especially useful as a developer sandbox:\n* You can use the services for your JUNIT integration tests\n* You can also run your application for development and testing\n\nFor Java developers\n
To run MCF there are a few things that you need\n
I now want to walk through the process of configuring Cloud Foundry\n
The first step is to register and login to CF.com\n\n\n
You then have to pick a unique domain name for your MCF.\n
CF then displays a configuration token that you must later enter into MCF\n
You then download and unzip MCF and open the micro.VMX\nWhich launches FUSION or VMware player\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Accessing MCF through a host name is pretty cool.\nBut it does require a DNS server.\nAnd until recently that required your PC to be online\nThe very latest version of MCF and VMC support a true offline mode.\n\n
The vmc micro status command shows the online/offline state\n When you first run the command you need to specify the paths to the VM and vmrun command\n Those values are saved away so you don&#x2019;t have to re-enter them\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
You switch between online and offline modes using the vmc micro online and offline commands\n Vmc micro offline switches to offline mode\n It reconfigures DNS..\n vmc micro online switches back to online mode\n ...\n
One of the neat things about MCF is that it supports remote debugging from STS.\nLet&#x2019;s look at that.\n\n
\n
\n
\n
\n
\n
Up until I&#x2019;ve been talking about the deployment side to PaaS.\nI now want to change gears and talk about how easy it is to create and consume services on Cloud Foundry\n
Cloud Foundry provides a variety of services\n
With Cloud Foundry, its easy to create an instance of one of these services.\nYou use the vmc create-service command, specify the type of the service and the name.\nA few seconds later you have a running service instance, \n
In order, for an application to use a service that service must be bound to the application.\nThere are a couple of different ways to do this.\nOne approach is to bind the service when the application is first deployed.\n\nThe push command as you whether you want to bind services to the application.\n
In order, for an application to use a service that service must be bound to the application.\nThere are a couple of different ways to do this.\nOne approach is to bind the service when the application is first deployed.\n\nThe push command as you whether you want to bind services to the application.\n
Another option is to use the bind-service command to bind a service to an already running application\n
You can also bind services from within STS\n
\nLet&#x2019;s look at how you deploy an application that consumes Cloud Foundry services\n
The survey application stores information about customers and their answers to survey questions.\n\nWhat&#x2019;s particulary interesting about this application is that it uses what we call cross-store persistence.\n\nCustomers are stored in a MySQL database.\nBut the survey questions are stored in MongoDB, which is a document-oriented NoSQL database.\n\n\n
\n
So how does binding actually work?\n\nWhat actually happens, is that CF sets an environment variable called VCAP_SERVICES.\nLike VCAP_APPLICATION its a JSON document.\nAnd it contains information about the services that have been bound to the application.\n\nFor example, with a MySQL database VCAP_SERVICES specifies the host, port, user name, password and schema name. An application can use this information to connect to the database.\n
There are a couple of different ways of accessing the service bindings.\n\nThe brute force approach is to get the value of the env var and parse the JSON.\nThat works in every language.\nBut it is a lot of work.\n
Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
Some frameworks simplify the process of accessing bound services.\nFor example, Cloud Foundry provides some really easy ways to access services from a Spring application.\n
Ruby also has some high-level support.\nCloud Foundry can automatically reconfigure a Ruby application to talk to the bound services.\n
\n
So this all good stuff.\nBut what if you want to access the services outside of application.\nFor example, you might want to run a database tool to dump or restore test data.\nOr you might want to use the services from a JUNIT integration that you run in your IDE\n\n
To support these use cases, Cloud foundry has a tool called Caldecott.\nCaldecott let&#x2019;s you create a tunnel to a service running within CF.\nIt works with both the MCF and also CF.com\n
To use caldecott you first need to install the Ruby gem.\n
Once you have done that you are ready to access the services.\nLet&#x2019;s look at a demo.\n