The Liberty Buildpack aims to remove the hassle of running Java applications on Cloud Foundry whether it is the simplified setup, auto-configuration of Liberty and Java EE references to cloud resources, reduced droplet size through selective provisioning of the runtime, or the zero-touch configuration and usage of services. There are times, however, when an application needs a feature that the buildpack does not yet provide. This talk will start by showing how to use and configure the Java buildpack and finish by showing how to extend the buildpack to ensure that IBM BlueMix Cloud Foundry is the best place to run your application. To build services and integrate them with BlueMix, you must implement the Service Broker API of Cloud Foundry for your services. This talk will explain how to write plugins to the Liberty Buildpack that will auto wire services your organization developed and integrated into CF making it easier for your apps to use the services in Cloud Foundry.
2. Please Note
IBM’s statements regarding its plans, directions, and intent are subject to change
or withdrawal without notice at IBM’s sole discretion.
Information regarding potential future products is intended to outline our general
product direction and it should not be relied on in making a purchasing decision.
The information mentioned regarding potential future products is not a
commitment, promise, or legal obligation to deliver any material, code or
functionality. Information about potential future products may not be incorporated
into any contract. The development, release, and timing of any future features or
functionality described for our products remains at our sole discretion.
Performance is based on measurements and projections using standard IBM
benchmarks in a controlled environment. The actual throughput or performance
that any user will experience will vary depending upon many factors, including
considerations such as the amount of multiprogramming in the user’s job stream,
the I/O configuration, the storage configuration, and the workload processed.
Therefore, no assurance can be given that an individual user will achieve results
similar to those stated here.
1
3. BlueMix & Cloud Foundry Concepts
Applications: Artifact that the end developer is building
Services: Code that BlueMix hosts that offers functionality for apps
ranging from utility functions to very complex business logic
Buildpack: A collection of code that is responsible for transforming
pushed application artifacts into a ready to run droplet, in a process
referred to as ‘staging’.
Droplet: A package containing everything that is needed in order to
successfully run your application, e.g. JVM, Liberty core libraries, the
application itself, short of the operating system.
Warden: The mechanism used to achieve application isolation in the
cloud foundry environment
Organizations & spaces: organizational units in the Cloud Foundry
infrastructure that can be used to store and track application resources
Users: Developer interacting with BlueMix
Boilerplate: Container of one application with multiple services
BOSH:
2
7. Deployment models
1. Entire service packaged and deployed by BOSH alongside
Cloud Foundry
2. Broker packaged and deployed by BOSH alongside Cloud
Foundry, rest of the service deployed and maintained by other
means
3. Broker and optionally service pushed as an application to
Cloud Foundry user space
4. Entire service, including broker, deployed and maintained
outside of Cloud Foundry by other means
6
8. Services in
BlueMix
BlueMix simplifies the use
of services by managing
the provisioning of new
instances of the service
and the binding of those
service instances to your
application.
7
9. WebSphere Liberty Buildpack
Buildpack for running applications on IBM WebSphere
Application Server Liberty Profile.
Designed to run "packaged" servers and web applications
Generates the liberty server configuration for a bound services
Simplify developers’ lives by requiring minimal configuration and
making it easy to consume services
Loads into the server only what is needed for a running
application
https://github.com/cloudfoundry/ibm-websphere-liberty-
buildpack
8
10. Responsibility of the Liberty Buildpack
The buildpack will convert and
environment variables provided by CF into configuration
variables for the Liberty server.
The variables end up in runtime-vars.xml, and are referenceable
from a pushed server.xml
Auto generate configuration for the bound services
Auto wire resources references to the appropriate cloud service
resource
Starting and stopping the Liberty server and controlling the
process environment
Generate the Liberty server configuration when war/ear files are
pushed
Pull in additional Liberty runtime packages when the bound
services need them
9
16. How to write cloud foundry service
Develop a service broker using Spring Service Broker - this
repository provides a template for building v2 service brokers in
Spring, and includes an example implementation for MongoDB
1. Fork the project
2. Implement 3 interfaces in the
package alternatively, you can use the included
and just implement the other 2 interfaces
3. Ensure your service impls are annotated with
4. Build the project and run the tests: gradle build
5. Push the broker to Cloud Foundry as an app:
6. Register your service broker with CF:
15
17. Developing a service broker
When developing new Service Broker, a few questions need to be
answered:
What happens when a new service instance is created?
• A new database is created on an existing MongoDB server
What happens when a new bind request is received?
• A new user is created for the database instance using the bind
request id sent by the cloud controller.
What credentials does an application need to bind to the service
instance?
• The URI of the MongoDB server, the database created as a
service instance, and the user account created as part of the
binding request
Look at existing examples from
16
20. External Service Providers
Third party services are on boarded to BlueMix via the IBM
Cloud Partner Marketplacehttp://www.ibm.com/cloud-
computing/us/en/partner-landing.html
You can send an email to joinnow@us.ibm.com requesting
information on how to become a BlueMix Partner Service.
19
21. Service Integration with the Liberty buildpack
BlueMix IBM Created services
• Configuration service
• SQLDB
• Monitoring service
• Auto Scaling service
• Security Service
• Data Cache
• Session Cache
• Log Analytics
• BLUAcceleration
• Elastic MQ
• Cloudant
BlueMix IBM Community Services
• MySQL
• PostgreSQL
• MongDB
• Twillio
20
Information about bound services is
available in the VCAP_SERVICES env var.
Some services are container managed.
(SessionCache) Require xml.
Some services can be either container
managed or application managed. (RDB)
Some services contain multiple features
which can be separately enabled.
(LogAnalysis)
Some services have local analogs (RDB,
mongo) and some do not (LogAnalysis)
Services may require client driver jars,
extension features (wxs esa), Liberty
features, bootstrapping.properties.
22. Service Provider Plugins
Service plugins are driven in the compile phase of the liberty Buildpack
Service plugins can be written to handle automatic configuration of a bound service
during application staging. This is also known as auto-configuration.
• One Service Plug-in for each service type (mongo, DataCache, SQLDB, etc.,)
Each service plugin implements the plugin API. A service plug-in requires :
• Service.yml -Configuration for the service
• Service.rb - Impl. class for the service
ServiceManager.rb in the liberty buildpack orchestrates the creation of service plugin
instances
• Parse VCAP_SERVICES to determine bound services
• Map each bound services to a plug-in instance type.
• Create instances and drive life-cycle
The same set of service plug-ins can be used to support service binding either at
application deployment time, or at post deployment time (late binding).
• This is due to re-stage being required for any service binding update
A default service plugin generates the runtime variables that are included in the
server.xml for every bound service
21
23. Service Provider API
• Service plugins can assume that the liberty server and the
application bits are extracted and available
• Service Brokers
22
26. Best Practices for service providers
Users will be provided an option to opt-out of auto-configuration
when the generated configuration is not correct or if the service
plugin cannot discern intent correctly
Services can provision features from liberty runtime extended in
the droplet by returning true in ?
Service Provider framework does NOT deal with partitioned
server.xml configuration
Service plugins should implement extensive logging using
Do not create dependencies between services
Play nice with other service plugins and main compile event
loop of the buildpack
Follow consistent schema naming conventions in
VCAP_SERVICES.
25
27. Java EE Resource Auto-wiring for IBM created BlueMix
services
26
28. Development Workflow for a service plugin
Fork open source liberty buildpack
Ensure that your service plugin adheres to the APIs and
guidelines laid down in this document
Provide good test coverage via rspec
Issue a github Pull Request against the OS Buildpack
Review of the PR ensues by committers of the liberty buildpack
Submitting the pull request will automatically run all of the rspec
and rubocop tests using TravisCI
If everything is green and the review is complete then a
committer can accept the pull request.
• This will run the tests for a second time
Code is merged into the buildpack!
Service Provider is responsible for keeping plugin impl up to
date with any CF buildpack API changes
27
29. Constraints on applications using services running on
Liberty in BlueMix
You can make any sort of TCP outbound connection
SSH/SSL/HTTP/HTTPS/<any protocol> from a container inside of CF. This
must be possible for apps running inside of BlueMix to connect to a wide
variety of services located on the internet
Applications cannot involve service resource interaction in a 2 phase commit
If the service is not available the application should
• Fallback and degrade gracefully when possible.
• Fail fast when fallbacks aren’t available and rapidly recover
28
30. Troubleshooting and Debugging service binding and
providers with the liberty buildpack
Print VCAP_SERVICES environment variable in the application
as a debug string
Use the Service console link from Ace to view the state of the
service
Document procedures for log retrieval and page out when a
critical service goes down in production
When everything else fails delete the service instance, rebind
and push the app
Please note that restart of the app after binding a service
instance will not cause a restage of the app
29
31. Interesting BlueMix sessions
Creating & Consuming Shared Services for Codename: BlueMix
- CSD-2776
A Deep Dive into the Liberty Buildpack on IBM BlueMix - AAI-
1713
Messaging in the cloud with Elastic MQ, MQ Light and BlueMix -
AMC-1897
Reduce the Complexity of Application Delivery & Focus on What
Matters with DevOps Services & BlueMix - AAD-2132
33. We Value Your Feedback
Don’t forget to submit your Impact session and speaker
feedback! Your feedback is very important to us – we use it to
continually improve the conference.
Use the Conference Mobile App or the online Agenda Builder to
quickly submit your survey
• Navigate to “Surveys” to see a view of surveys for sessions
you’ve attended
32