49
Andy Piper | @andypiper | [email protected] Cloud Foundry Developer Advocate, Pivotal Run Your Java Apps on Cloud Foundry

Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Embed Size (px)

DESCRIPTION

Presented at JAX London 2013 Public, private, and hybrid; software, platform, and infrastructure. This talk will discuss the current state of the Platform-as-a-Service space, and why the keys to success lie in enabling developer productivity, and providing openness and choice. We'll do this by considering the success of Open Source in general, look at the Cloud Foundry project, and find out why Cloud Foundry-based PaaSes are the best places to host your applications written in Java and other JVM-based languages.

Citation preview

Page 1: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Andy Piper | @andypiper | [email protected] Cloud Foundry Developer Advocate, Pivotal

Run Your Java Apps on Cloud Foundry

Page 2: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Hello I’m Andy

Page 3: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

a few things about me

Developer Advocate @ Cloud Foundry social web enthusiast

maker, educator, LEGO fan OSS contributor

Eclipse Project Lead (Paho / MQTT) excited by “what’s next”, Internet of Things, etc.

!

!

@andypiper [email protected]

Page 4: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Developer Advocate? hellz to the yeah!

Page 5: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)
Page 6: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

@andypiper !

[works on] !

#cloudfoundry !

[at] !

@gopivotal

Page 7: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

1. Why is an Open Cloud Platform important? 2. What is Cloud Foundry? 3. Java support in the open cloud

Page 8: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Why is an Open Cloud Platform important?

Page 9: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

An important year in software

1991

Hello everybody out there using minix - !

I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu) for 386(486) AT clones.

From: [email protected]: comp.os.minixDate: 25 Aug 91 20:57:08 GMTOrganization: University of Helsinki

Page 10: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

~21 years later: Linux has won

Page 11: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Linux runs everywhere (even old versions, on crashy airline entertainment systems...)

#P0WN ALL TEH

GADGETZ !

Page 12: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

It works.

Page 13: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Don’t be locked-in do you know what is coming tomorrow?

Page 14: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

What is Cloud Foundry?

Page 15: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

3 layers IaaS, PaaS, SaaS

Infrastructure

Platform

SoftwareGmail, Salesforce,

Flickr, Google Docs...

Amazon EC2, Google CE, OpenStack, vSphere, Joyent, Cloud Stack,

Eucalyptus...

Google AppEngine, Heroku, Cloud Foundry, EngineYard, Apprenda...

Page 16: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Cloud Foundry - the Open PaaS

Open Source

Micro&Clouds

Private&Clouds

Public&Clouds

CUSTOM SERVICES

CUSTOM RUNTIMES

Page 17: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

“… we believe that the best solution should be available on top of any cloud and not just be locked into EC2”

!- Mike Soby in JAX Magazine

Special Edition

Page 18: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

All the pieces to make your own!

“if you can’t open it, you don’t own it” (O’Reilly MAKE)

Page 19: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Open & public from the start Code all on Github

Page 20: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Why is it so hard...? A real deployment flow (!)

Page 21: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

An alternative approach... Cloud Foundry can make it simpler!

cf#iaas.yml+provision+<my+cloud>+add_capacity+<my+cloud>

target+<my+cloud>+push+<my+app>+create+<my+services>+bind+<my+services>+scale+<my+app>++100

OPERATOR DEVELOPER

Cloud Deployment: 2-4 hours App Deployment: 30-90 seconds

Page 22: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

C L O U D F O U N D R Y Demo

Page 23: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Java (and JVM language) support in Cloud Foundry

Page 24: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

From VM-centric to Application Centric

Infrastructure One

JVM

VM

Infrastructure One

Infrastructure Two

App

Container 1

App Server

JVMContainer 2

App Server

JVM

Dev Framework Dev Framework

App Server

Configurations Manifests, Automations

Infrastructure Two

JVM

VM

Dev Framework

App Server

Configurations

App App App

Page 25: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Buildpacks

Buildpacks are responsible for preparing the machine image for an application

Application

Container

Runtime

Operating System

LibrariesDEA

Buildpack }Droplet

Page 26: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

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 - emerging convention

Page 27: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Built-in Buildpacks

→→→

Page 28: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Tested Buildpackshttps://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks

LanguagesContainers

Haskell

Page 29: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Java Buildpack

Supports a variety of JVM languages, containers, and frameworks with a modular, configurable, and extensible design

Page 30: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

“The primary objective of the Java buildpack is to be the easiest way to run a Java application. The word easiest can mean a lot of things, but to me it means

that a developer can push an application and have an “it just works™” experience.”

!- Ben Hale, Java buildpack engineer

http://blog.cloudfoundry.com/2013/09/06/introducing-the-cloud-foundry-java-buildpack/

Page 31: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Java Buildpack Concepts

Containers Frameworks

JREsOpenJDK, etc.

Java main() Tomcat Groovy

Spring Boot CLI Play

Spring config Play config

Play JPA config New Relic

Page 32: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

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 CLIone 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

Page 33: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

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

Page 34: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

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 →

Page 35: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Choice!

• IBM donated WebSphere Liberty Buildpack http://blog.cloudfoundry.com/2013/09/09/ibm-websphere-liberty-buildpack-contributed-to-cloud-foundry/

• Other forks add additional containers and frameworks - Jonas, Dropwizard, Karaf, etc

Page 36: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Tooling support

$ mvn clean package cf:push!$ gradle clean assemble cf-push

http://blog.cloudfoundry.com/2013/10/29/java-tooling/

Page 37: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

the new Spring spring.io

Page 38: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

WEB

Controllers, REST,WebSocket

INTEGRATION

Channels, Adapters,Filters, Transformers

BATCH

Jobs, Steps,Readers, Writers

BIG DATA

Ingestion, Export,Orchestration, Hadoop

DATA

NON-RELATIONALRELATIONAL

CORE

GROOVYFRAMEWORK SECURITY REACTOR

GRAILS

Full-stack, Web

XD

Stream, Taps, Jobs

BOOT

Bootable, Minimal, Ops-Ready

Page 39: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Groovy and Spring Boot

Page 40: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Groovy and Spring Boot

Page 41: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Groovy and Spring Boot

Page 42: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Spring and the Cloud

• Goal: deploy Spring apps to the cloud without changing a single line of code

• Cloud Foundry automatically re-configures bean definitions to bind to cloud services

• Works with Spring and Grails

Page 43: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Portability

Page 44: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

S P R I N G Demo

Page 45: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

… and finally …

Page 46: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Try It! http://run.pivotal.io

Page 47: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Join us! ... a pull request is all it takes!

Page 48: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Connect

http://twitter.com/andypiper http://andypiper.co.uk

http://slideshare.net/andypiper

Page 49: Run Your Java Code on Cloud Foundry - Andy Piper (Pivotal)

Credits

• Padlock http://www.flickr.com/photos/bpc009/3328427457/

• Other images are author’s own, or royalty-free and CC-licensed works from Wikimedia Commons

• Thanks to Scott Frederick, Josh Long and Guillaume Laforge for content