Presentation given at Spring One 2013 by Cornelia Davis and Scott Frederick. Covers the different types of Cloud Foundry services, including marketplace services on run.pivotal.io, user defined service instances and Cloud Foundry Service Brokers. Also covers buildpacks, the mechanism for bringing application context to the applications that are deployed to and run within the Cloud Foundry PaaS.
6. When you cf push
VM for Service
Instances
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
MySQL
(process)
7. When you cf push
VM for Service
Instances
provision (HTTP)
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
MySQL
(process)
8. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
MySQL
(process)
9. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
up to you
MySQL
(process)
10. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
up to you
MySQL
(process)
11. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
up to you
MySQL
(process)
12. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
bind (HTTP)
Router
CLI
Browse
5
Thursday, November 21, 13
Service
Broker
(i.e. mysql)
DEA
up to you
MySQL
(process)
13. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
bind (HTTP)
Router
CLI
Browse
5
Thursday, November 21, 13
bind (HTTP)
DEA
Service
Broker
(i.e. mysql)
up to you
MySQL
(process)
14. When you cf push
VM for Service
Instances
provision (HTTP)
provision (HTTP)
Cloud
Controller
bind (HTTP)
Router
CLI
Browse
5
Thursday, November 21, 13
bind (HTTP)
DEA
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
15. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
Cloud
Controller
bind (HTTP)
Router
CLI
Browse
5
Thursday, November 21, 13
bind (HTTP)
DEA
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
16. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
Cloud
Controller
bind (HTTP)
Router
CLI
Browse
5
Thursday, November 21, 13
bind (HTTP)
DEA
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
17. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
CLI
Cloud
Controller
bind (HTTP)
bind (HTTP)
go ahead and
deploy (HTTP)
Browse
5
Thursday, November 21, 13
Router
...
DEA
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
18. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
CLI
Cloud
Controller
bind (HTTP)
bind (HTTP)
go ahead and
deploy (HTTP)
Browse
5
Thursday, November 21, 13
Router
...
DEA
Droplet
credentials
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
19. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
CLI
Cloud
Controller
bind (HTTP)
bind (HTTP)
go ahead and
deploy (HTTP)
Browse
5
Thursday, November 21, 13
Router
...
DEA
Droplet
credentials
Service
Broker
(i.e. mysql)
up to you
up to you
MySQL
(process)
20. When you cf push
VM for Service
Instances
credentials
provision (HTTP)
provision (HTTP)
CLI
Cloud
Controller
bind (HTTP)
bind (HTTP)
go ahead and
deploy (HTTP)
Browse
5
Thursday, November 21, 13
Router
...
Service
Broker
(i.e. mysql)
up to you
MySQL
(process)
up to you
DEA
Droplet
credentials
Note:
• Don’t call ‘em “Gateways” anymore
• Broker only used during
•(un)provision
•(un)bind
22. Agenda
§Extending services offerings within run.pivotal.io
–Partnering
§Building services
–Into your own Cloud Foundry
§User-provided service instances
–For access to pre&externally-provisioned services
Thursday, November 21, 13
29. Cloud Foundry Services
• There is only one built in - mysql
– or many more depending on how you count
• How to build them - the evolution:
– CF v1, subclass Ruby base classes
– CF v2, a RESTful protocol (which is itself evolving)
Polyglot!
• There are three parts to the protocol...
11
Thursday, November 21, 13
30. 1Broker Registers Offerings
On Broker Startup...
Browser
12
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
31. 1Broker Registers Offerings
On Broker Startup...
Authenticate
Browser
12
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
32. 1Broker Registers Offerings
On Broker Startup...
CLI
Authenticate
Thursday, November 21, 13
UAA
Router
Browser
12
Service
Broker
(i.e. mysql)
token
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
33. 1Broker Registers Offerings
On Broker Startup...
CLI
Authenticate
token
Browser
12
Thursday, November 21, 13
UAA
Router
Services Catalog
Ge
ta
t ca
log
P)
TT
(H
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
34. 1Broker Registers Offerings
On Broker Startup...
CLI
Authenticate
token
Browser
12
Thursday, November 21, 13
UAA
Router
Services Catalog
Ge
Cloud
Controller
ta
t ca
da
Up
te
log
P)
TT
(H
alo
cat
g
Service
Broker
(i.e. mysql)
VM for Service
Instances
P)
TT
(H
DEA
My Service
(process)
35. 2Broker Services (un)provision and (un)bind
Prerequisite...
13
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
Cloud
Controller
VM for Service
Instances
My Service
(process)
36. 2Broker Services (un)provision and (un)bind
Prerequisite...
shared secret
13
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
Cloud
Controller
VM for Service
Instances
My Service
(process)
37. 2Broker Services (un)provision and (un)bind
Prerequisite...
vid
es
ha
13
Thursday, November 21, 13
red
sec
ret
Service
Broker
(i.e. mysql)
(H
UAA
pro
Router
CLI
shared secret
VM for Service
Instances
TT
P)
Cloud
Controller
My Service
(process)
38. 2Broker Services (un)provision and (un)bind
Browser
14
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
39. 2Broker Services (un)provision and (un)bind
Browser
14
Thursday, November 21, 13
UAA
Router
CLI
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
40. Browser
14
Thursday, November 21, 13
UAA
Router
CLI
2Broker Services (un)provision and (un)bind
(un
)
vi
pro
sio
n
P)
TT
(H
Service
Broker
(i.e. mysql)
up to you
VM for Service
Instances
My Service
(process)
Cloud
Controller
DEA
41. CLI
2Broker Services (un)provision and (un)bind
Browser
14
Thursday, November 21, 13
UAA
Router
credentials
(un
Cloud
Controller
)
vi
pro
)b
(un
ind
sio
n
P)
TT
(H
P)
TT
(H
DEA
Droplet
credentials
Service
Broker
(i.e. mysql)
up to you
VM for Service
Instances
My Service
(process)
42. CLI
2Broker Services (un)provision and (un)bind
Browser
14
Thursday, November 21, 13
UAA
Router
credentials
(un
Cloud
Controller
)
vi
pro
)b
(un
ind
sio
n
P)
TT
(H
P)
TT
(H
DEA
Droplet
credentials
Service
Broker
(i.e. mysql)
up to you
VM for Service
Instances
My Service
(process)
43. 3Orphan Management
CLI
Broker is responsible for eventual consistency...
15
Thursday, November 21, 13
UAA
Router
Services Catalog
Cloud
Controller
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
44. 3Orphan Management
Broker is responsible for eventual consistency...
CLI
Authenticate
token
15
Thursday, November 21, 13
UAA
Router
Services Catalog
Cloud
Controller
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
45. 3Orphan Management
Broker is responsible for eventual consistency...
CLI
Authenticate
token
15
Thursday, November 21, 13
UAA
Router
Services Catalog
Ge
Cloud
Controller
ta
t ca
log
P)
TT
(H
Service
Broker
(i.e. mysql)
VM for Service
Instances
My Service
(process)
46. 3Orphan Management
Broker is responsible for eventual consistency...
CLI
Authenticate
token
15
Thursday, November 21, 13
UAA
Router
Services Catalog
Ge
Cloud
Controller
ta
t ca
log
P)
TT
(H
Service
Broker
(i.e. mysql)
up to you
VM for Service
Instances
My Service
(process)
47. New (V2) Services API
• Simplifies things a bunch!
• Unidirectional - everything initiated from Cloud Controller
• Asynchronous provisioning
• From V1 RESTful Services API:
– Replace offerings registration with endpoint that allows the CC to
GET the offerings
– Remove orphan management
16
Thursday, November 21, 13
48. It’s Up To YOU Patterns
One option (CF v1 services)...
VM for Service
Instances
My Service
(process)
VM for Service
Broker
Service
Broker
VM for Service
Instances
My Service
(process)
Node
Node
VM for Service
Instances
NATS
17
Thursday, November 21, 13
My Service
(process)
Node
49. It’s Up To YOU Patterns
One option (CF v1 services)...
VM for Service
Instances
My Service
(process)
VM for Service
Broker
provision
Service
Broker
VM for Service
Instances
My Service
(process)
Node
Node
VM for Service
Instances
NATS
17
Thursday, November 21, 13
My Service
(process)
Node
50. It’s Up To YOU Patterns
One option (CF v1 services)...
VM for Service
Instances
My Service
(process)
VM for Service
Broker
provision
Service
Broker
VM for Service
Instances
My Service
(process)
Node
Node
VM for Service
Instances
NATS
17
Thursday, November 21, 13
My Service
(process)
Node
51. It’s Up To YOU Patterns
One option (CF v1 services)...
VM for Service
Instances
My Service
(process)
VM for Service
Broker
provision
Service
Broker
VM for Service
Instances
My Service
(process)
Node
Node
VM for Service
Instances
NATS
17
Thursday, November 21, 13
My Service
(process)
Node
52. It’s Up To YOU Patterns
One option (CF v1 services)...
VM for Service
Instances
My Service
(process)
VM for Service
Broker
provision
Service
Broker
VM for Service
Instances
My Service
(process)
Node
Node
VM for Service
Instances
NATS
17
Thursday, November 21, 13
My Service
(process)
Node
53. It’s Up To YOU Patterns
Another...
VM for Service
Instances
VM for Service
Broker
VM for Service
Instances
Warden
Warden
Svc Process
Svc Process
Service
Broker
Node
Node
VM for Service
Instances
Warden
NATS
18
Thursday, November 21, 13
Svc Process
Node
54. It’s Up To YOU Patterns
Another...
VM for Service
Instances
VM for Service
Broker
provision
VM for Service
Instances
Warden
Warden
Svc Process
Svc Process
Service
Broker
Node
Node
VM for Service
Instances
Warden
NATS
18
Thursday, November 21, 13
Svc Process
Node
55. It’s Up To YOU Patterns
Another...
VM for Service
Instances
Warden
VM for Service
Broker
provision
Svc Process
Svc Process
Svc Process
Service
Broker
VM for Service
Instances
Warden
Warden
Node
Node
VM for Service
Instances
Warden
NATS
18
Thursday, November 21, 13
Svc Process
Node
56. It’s Up To YOU Patterns
Another...
VM for Service
Instances
Warden
VM for Service
Broker
provision
Svc Process
Svc Process
Svc Process
Service
Broker
VM for Service
Instances
Warden
Warden
Node
Node
VM for Service
Instances
Warden
NATS
18
Thursday, November 21, 13
Svc Process
Node
57. It’s Up To YOU Patterns
And another...
VM for Service
Instances
VM for Service
Instances
VM for Service
Broker
Service
Broker
Node
Node
VM for Service
Instances
NATS
19
Thursday, November 21, 13
Node
58. It’s Up To YOU Patterns
And another...
VM for Service
Instances
VM for Service
Instances
VM for Service
Broker
provision
Service
Broker
Node
Node
VM for Service
Instances
NATS
19
Thursday, November 21, 13
Node
59. It’s Up To YOU Patterns
And another...
VM for Service
Instances
VM for Service
Instances
VM for Service
Broker
provision
Service
Broker
Node
Node
VM for Service
Instances
NATS
19
Thursday, November 21, 13
Node
60. It’s Up To YOU Patterns
And another...
VM for Service
Instances
Warden
VM for Service
Broker
provision
VM for Service
Instances
Warden
Svc Process
Svc Process
Service
Broker
Node
Node
VM for Service
Instances
Warden
NATS
19
Thursday, November 21, 13
Svc Process
Node
61. It’s Up To YOU Patterns
And another...
VM for Service
Instances
Warden
VM for Service
Broker
provision
VM for Service
Instances
Warden
Svc Process
Svc Process
Service
Broker
Node
Node
VM for Service
Instances
Warden
NATS
19
Thursday, November 21, 13
Svc Process
Node
62. BOSH deployment
packages
- service broker
- your impl
- service node
- services binaries
- services warden
- your node impl
Provisions
broker VMs
jobs
- service broker
- ref service broker pkg
- start web service
- service node
- ref service node pkg
- start node
Configure shared secret (for example)
20
Thursday, November 21, 13
Provisions
service VMs
70. Tell ‘em what you told ‘em...
§Extending services offerings within run.pivotal.io
–Partnering
§Building services
–Into your own Cloud Foundry
§User-provided service instances
–For access to pre&externally-provisioned services
Thursday, November 21, 13
73. Staging and Buildpacks
Buildpacks are responsible for preparing
the machine image for an application
Application
Buildpack
DEA
Container
Libraries
Runtime
Operating System
27
Thursday, November 21, 13
}
Droplet
74. Compatibility
Cloud Foundry buildpacks follow the Heroku buildpack design
Cloud Foundry and Heroku buildpacks are compatible
(if you take care to make them compatible)
Other PaaS providers are adopting the buildpack design
28
Thursday, November 21, 13
75. Built-in or BYO
cf push
cf push --buildpack <url>
The application is tested
against a set of curated
buildpacks
The buildpack is
referenced by a Git URL
29
Thursday, November 21, 13
78. Buildpack API
/bin/detect app_directory
Inspect app bits to determine buildpack applicability
/bin/compile app_directory cache_directory
Download and install runtime, container, packages, libraries;
install app bits as necessary
/bin/release app_directory
Build app start command
32
Thursday, November 21, 13
79. /bin/detect
Inspect the app bits to determine if the buildpack knows how
to handle the application
Gemfile exists
package.json exists
setup.py exists
On match, return exit code 0 and
write to STDOUT a string identifying the buildpack
(often just the name of the language supported)
33
Thursday, November 21, 13
80. /bin/detect
$ cf push
DEA iterates over built-in
buildpacks calling
/bin/detect scripts
until one of them returns
exit code 0
34
Thursday, November 21, 13
$ cf push --buildpack <url>
/bin/detect is
not called
81. /bin/compile
Download and install any necessary
runtime (Java VM, Ruby interpreter, JavaScript interpreter)
container (web server)
support libraries, packages, modules (Ruby gems, NPM packages)
...and then installing the app bits into the runtime or container
35
Thursday, November 21, 13
82. /bin/compile Caching
Runtime, container, and support packages are downloaded
from sources external to Cloud Foundry
DEA provides a location for storing downloaded artifacts to
speed subsequent staging operations
36
Thursday, November 21, 13
83. /bin/release
Build a YAML-formatted hash with three possible keys
addons: []
config_vars: {}
default_process_types:
web: <start command>
On Cloud Foundry, currently only the web: value
is used to get the start command for the app
37
Thursday, November 21, 13
84. Java Buildpack
Supports a variety of JVM languages, containers, and
frameworks with a modular, configurable, and extensible design
38
Thursday, November 21, 13
87. Container Detection Criteria
Java main()
META-INF/MANIFEST.MF exists with
Main-class attribute set
Tomcat
WEB-INF directory exists
Groovy
.groovy file with a main() method, or
.groovy file with no classes, or
.groovy file with a shebang (#!) declaration
Spring Boot CLI
one or more POGO .groovy files with no
main() method, and
no WEB-INF directory
Play
start and lib/play.play_*.jar exist
Choose zero or one
41
Thursday, November 21, 13
88. Framework Detection Criteria
Spring
spring-core*.jar exists
Play config
Play application detected
Play JPA config
play-java-jpa plugin exists in app
New Relic
New Relic service bound to app
Choose all that apply
42
Thursday, November 21, 13
89. /bin/compile Output Example
-----> Downloaded app package (18M)
-----> Downloading OpenJDK 1.7.0_21 JRE (17.5s)
Expanding JRE to .java (1.4s)
-----> Downloading Auto Reconfiguration 0.7.1 (1.4s)
Modifying /WEB-INF/web.xml for Auto Reconfig
-----> Downloading Tomcat 7.0.42 (3.5s)
Expanding Tomcat to .tomcat (0.2s)
Downloading Buildpack Tomcat Support 1.1.1 (0.0s)
-----> Uploading droplet (55M)
43
Thursday, November 21, 13
DEA
Buildpack
DEA
90. See What’s Going On
$ cf files <app-name> app
.buildpack-diagnostics/
.java/
.lib/
.tomcat/
Buildpack-installed runtime
Buildpack-installed support libraries
Buildpack-installed container
META-INF/
WEB-INF/
assets/
44
Thursday, November 21, 13
DEA-downloaded application files
91. See What’s Going On
$ cf files <app-name> staging_info.yml
detected_buildpack: openjdk-1.7.0_21, tomcat-7.0.42,
spring-auto-reconfiguration-0.7.1
start_command: JAVA_HOME=.java
JAVA_OPTS="-Dhttp.port=$PORT
-Djava.io.tmpdir=$TMPDIR -XX:MaxPermSize=52428K
-XX:OnOutOfMemoryError=./.buildpack-diagnostics/killjava
-Xmx384M -Xss1M" .tomcat/bin/catalina.sh run
45
Thursday, November 21, 13
92. Customization
Two ways to customize the Java buildpack
Configure artifacts used by standard JREs, Containers, and Frameworks
Extend the buildpack with your own JREs, Containers, and Frameworks
Customization is done by forking the buildpack
46
Thursday, November 21, 13
93. Customization by Configuration
Configuration files in java-buildpack/config determine the
behavior of a JRE, Container, or Framework
# http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/index.yml
--1.6.0_27: http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/openjdk-1.6.0_27.tar.gz
1.7.0_21: http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/openjdk-1.7.0_21.tar.gz
1.7.0_25: http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/openjdk-1.7.0_25.tar.gz
1.8.0_M6: http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/openjdk-1.8.0_M6.tar.gz
1.8.0_M7: http://download.pivotal.io.s3.amazonaws.com/openjdk/lucid/x86_64/openjdk-1.8.0_M7.tar.gz
# cloudfoundry/java-buildpack/config/openjdk.yml
--version: 1.7.0_+
repository_root: "http://download.pivotal.io.s3.amazonaws.com/openjdk/{platform}/{architecture}"
memory_sizes:
memory_heuristics:
heap: 0.75
permgen: 0.1
stack: 0.05
native: 0.1
47
Thursday, November 21, 13
94. Customization by Configuration
Example: customizing the Tomcat artifact for download
# http://files.example.com/tomcat-custom/index.yml
--7.0.40: http://files.example.com/tomcat-custom/tomcat-7.0.40.tar.gz
7.0.41: http://files.example.com/tomcat-custom/tomcat-7.0.41.tar.gz
7.0.42: http://files.example.com/tomcat-custom/tomcat-7.0.42.tar.gz
# cloudfoundry/java-buildpack/config/tomcat.yml
--version: 7.0.42
repository_root: "http://files.example.com/tomcat-custom"
support:
version: 1.1.+
repository_root: "http://files.example.com/tomcat-buildpack-support"
48
Thursday, November 21, 13
95. Customization by Configuration
Tomcat container supports simple customization of
context.xml and server.xml.
cloudfoundry/java-buildpack/resources/tomcat/conf
context.xml
server.xml
49
Thursday, November 21, 13
96. Customization by Extension
Implement a JRE, Container, or Framework support class as
one Ruby file in the appropriate directory
cloudfoundry/java-buildpack/lib/java_buildpack
jre
container
framework
(with additional support classes as necessary)
50
Thursday, November 21, 13
97. Customization by Extension
Support class types have similar interfaces, following the
buildpack scripts naming conventions
# initialize the support class with platform information provided in context
# context includes app_dir, lib_dir, environment, java_home, java_opts, vcap_application, vcap_services
def initialize(context)
# return a String or an Array<String> that uniquely identifies the container/framework/jre, or nil
def detect
# download and unpack the container/framework/jre, and transform the application as necessary
def compile
# create and return the command to run the application with (containers) or add options to
context[:java_opts] (frameworks)
def release
51
Thursday, November 21, 13
98. Customization by Extension
Add new support class to config/components.yml
--containers:
- "JavaBuildpack::Container::Groovy"
- "JavaBuildpack::Container::Main"
- "JavaBuildpack::Container::SpringBootCli"
- "JavaBuildpack::Container::Tomcat"
- "JavaBuildpack::Container::Play"
jres:
- "JavaBuildpack::Jre::OpenJdk"
frameworks:
- "JavaBuildpack::Framework::JavaOpts"
- "JavaBuildpack::Framework::NewRelic"
- "JavaBuildpack::Framework::PlayAutoReconfiguration"
- "JavaBuildpack::Framework::PlayJpaPlugin"
- "JavaBuildpack::Framework::SpringAutoReconfiguration"
52
Thursday, November 21, 13
99. Customization
Much more information and documentation included in the
GitHub repository
https://github.com/cloudfoundry/java-buildpack
53
Thursday, November 21, 13