Top Banner
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Extending the Platform Kenny Bastani @kennybastani
60

Extending the Platform with Spring Boot and Cloud Foundry

Jan 07, 2017

Download

Software

Kenny Bastani
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Extending the PlatformKenny Bastani

@kennybastani

Page 2: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 2

@kennybastaniSpring Developer Advocate

Page 3: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

What makes an application legacy?

3

Page 4: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

What makes an application legacy?• How fast can you make changes to the application and deliver it into

production?• How much work is it to upgrade the application framework?

4

Page 5: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Legacy is an architecture problem

5

Page 6: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Monolith

6

Page 7: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 7

Microservices…

Page 8: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

If we're creating 10x the number of apps, we're creating 10x the technical debt

8

Page 9: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

What does your microservice architecture look like in 10 years?

9

Page 10: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

If you have to implement the same thing in every application, it should be provided

by the platform as a service

10

Page 11: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Do this successfully, and the only thing is left is the valuable business logic

11

Page 12: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

The two road blocks of cloud native

• Legacy applications • Legacy culture

12

Page 13: Extending the Platform with Spring Boot and Cloud Foundry

Legacy culture looks like this

Page 14: Extending the Platform with Spring Boot and Cloud Foundry

Legacy applications look like this

Page 15: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

How do we do better?

15

Page 16: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Platform Engineering

16

Page 17: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Platform Engineering• Everything that sits around your applications is vital to supporting the health of

your applications

• Unfortunately, anything that is not business logic is going to make it harder to upgrade your application later

• Platform engineering is the art of automating standards in an application architecture by reducing redundancy across applications

17

Page 18: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Redundancy in code creates technical debt.

In microservices, multiply that debt by the number of apps

18

Page 19: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot + Cloud Foundry Service Brokers

19

Page 20: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Backing services

20

Page 21: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Online Store Example

21

Page 22: Extending the Platform with Spring Boot and Cloud Foundry
Page 23: Extending the Platform with Spring Boot and Cloud Foundry

Backing services

Microservices

Page 24: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot

24

Page 25: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Platform engineers can take an opinionated view on how application developers will consume services

25

Page 26: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Cloud Foundry Service Brokers• The Cloud Foundry marketplace is similar to the idea of starter projects in Spring

Boot

• Services can be offered on Cloud Foundry and bound to your application deployments

• These marketplace services can be seen as backing services for your applications

26

Page 27: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 27

Microservices…

Page 28: Extending the Platform with Spring Boot and Cloud Foundry

Backing services

Microservices

Page 29: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Amazon S3 Service Broker• The demo for this presentation is going to create an Amazon S3 service broker

• We’ll release the broker to PCF Dev

• Extend Spring Boot to automatically consume service instances from the broker

• Deploy Spring Boot S3 browser that uses a starter project to connect to Amazon S3

29

Page 30: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Cloud Controller• The Cloud Controller is the contract that Cloud Foundry exposes over HTTP as a

REST API

• We can create service brokers that implement expectations from this contract to allow CF and other broker applications to talk to each other

30

Page 31: Extending the Platform with Spring Boot and Cloud Foundry
Page 32: Extending the Platform with Spring Boot and Cloud Foundry
Page 33: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot Service Broker Template• The Spring team maintains an example project that provides the boiler plate for

creating custom service brokers using Spring Boot

• https://github.com/spring-cloud/spring-cloud-cloudfoundry-service-broker

33

Page 34: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Implementing the service contracts• Service Catalog• Service Instances• Service Bindings

34

Page 35: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Service Catalog

35

Page 36: Extending the Platform with Spring Boot and Cloud Foundry
Page 37: Extending the Platform with Spring Boot and Cloud Foundry
Page 38: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Service Instances• Each method in the interface represents the implementation of a repository

pattern• Controls the lifecycle of resources on AWS that provide exclusive access to a

S3 bucket• The two resources that we will manage are:

• S3 buckets• IAM users

38

Page 39: Extending the Platform with Spring Boot and Cloud Foundry
Page 40: Extending the Platform with Spring Boot and Cloud Foundry
Page 41: Extending the Platform with Spring Boot and Cloud Foundry
Page 42: Extending the Platform with Spring Boot and Cloud Foundry
Page 43: Extending the Platform with Spring Boot and Cloud Foundry
Page 44: Extending the Platform with Spring Boot and Cloud Foundry
Page 45: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Service Bindings• The goal of the Amazon S3 Broker is to create S3 buckets that can be

automatically bound to an application

• Further, we want to make the service as easy to consume in a cloud native environment using Spring Boot starter projects to auto-configure the connection

• The result of this is that a service binding will attach to a Cloud Foundry deployment and inject the environment variables into the application’s container

• Our Spring Boot application will look for those environment variables at runtime and automatically configure an S3 connection

45

Page 46: Extending the Platform with Spring Boot and Cloud Foundry
Page 47: Extending the Platform with Spring Boot and Cloud Foundry
Page 48: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Releasing the Service Broker• There are multiple options for releasing service brokers

• Deploy as a CF app• Release with BOSH

48

Page 49: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Why should we use BOSH to release a service broker instead of deploying the application with Cloud Foundry?

49

Page 50: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

It depends on the virtualized compute resources you intend to manage with your

custom broker

50

Page 51: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

When to use BOSH• When you need to orchestrate resources with the IaaS provider that your CF

deployment uses

• Virtual machines

• Network resources

• BOSH provides a director API you can use to manage IaaS resources

• Portable with different IaaS providers that have a BOSH CPI

51

Page 52: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

When not to use BOSH• When you do not need to manage resources using the IaaS

• Example:

• Amazon S3

• Basically any AWS service that has an SDK

• Sometimes we just want to wrap another cloud service in a service broker, and that is OK

52

Page 53: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Releasing with Cloud Foundry• Let’s jump into code and release the S3 service broker as a CF deployment

53

Page 54: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Release steps• Create MySQL database as a service binding for the S3 broker• Build and push the S3 broker app• Bind Amazon AWS credentials as environment variables• Restage the S3 broker• Create service broker using CF CLI• Enable marketplace access to S3 broker• Create new service instance named s3-service

54

Page 55: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Extending Spring Boot• We can create a starter project that includes an Amazon S3 template for

consuming S3 service instances• All we need to do is to include the Amazon S3 starter project as a dependency

55

Page 56: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Custom Spring Boot starter projects• We need to create two project modules

• Auto-configuration project with the client libraries to consume a service instance (Amazon S3 Template)

• Basic starter dependency project that includes the auto-configuration project using Maven

56

Page 57: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Conclusion

57

Page 58: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Platforms are forever

58

Page 59: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Build value into the platform and reduce redundancies early in microservice

architectures

59

Page 60: Extending the Platform with Spring Boot and Cloud Foundry

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Learn More. Stay Connected.

Thanks!

@kennybastani on [email protected]/blog

@pivotalpivotal.io/blog

@pivotalcfhttp://engineering.pivotal.io