Slide 1

Slide 1 text

Service Brokers Deep Dive Singapore Spring User Group @sergiu_bodiu 2016 September 9

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

How hard it is to make changes to an App How often can I deploy that App

Slide 4

Slide 4 text

© Copyright 2013 Pivotal. All rights reserved. 4 Pivotal At-a-Glance • A startup: founded April 2013 with 1250 employees (“Pivots”) • Joint Venture: Spun out of VMware & EMC, with investment from GE • Proven Leadership: Paul Maritz, CEO • Vision: A platform at the intersection of apps, big data and analytics https://techcrunch.com/2016/05/09/pivotal-confirms-series-c-round-is-actually-over-650-million/

Slide 5

Slide 5 text

The Value of Going Fast

Slide 6

Slide 6 text

Tech User Stories + Domain 
 Modeling Reverse Engineering Invest Biz User Stories Cards Bank Decomposition Backlog Build Services Reusable Service Catalog Business Citi’s approach using Microservices

Slide 7

Slide 7 text

That just leads to… Photo credit Viacom Entertainment Group Chopping up or rebuilding the platform in the cloud will be your initial INSTINCT

Slide 8

Slide 8 text

• How to fix my legacy System? • How to fix my culture to Innovate?

Slide 9

Slide 9 text

© Copyright 2016 Pivotal. All rights reserved. Amazon S3 Service Broker • The goal of the Amazon S3 Broker is to create S3 buckets that can be automatically bound to an application.
 • The service will be using Spring Boot starter projects to auto-configure the connection as easy to consume in a cloud native environment. Cloud Foundry will 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 .

Slide 10

Slide 10 text

© Copyright 2016 Pivotal. All rights reserved. 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

Slide 11

Slide 11 text

© Copyright 2016 Pivotal. All rights reserved. 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.

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Who is a DevOps Consultant Bridging the gap between projects and operations by using Agile techniques in development, project management and system administration. 13 hIp://itrevoluLon.com/authors/patrick-debois

Slide 14

Slide 14 text

14 “Agile Infrastructure” - Andrew Clay Shafer and
 Patrick Debois Agile 2008 conference Use DevOps

Slide 15

Slide 15 text

DEV learn from OPS to think about Resources (CPU, RAM, Disk) Services (Start, Stop, Status) Dependencies (Start DB before App) Logfiles (Rotate, Remove) Disk Space Monitoring and Alarming 15

Slide 16

Slide 16 text

OPS learn from DEV to think about Incremental Improvement Infrastructure as Code Version Control System (git, mercurial…) Coding (OO, Functions, Libraries …) Code Quality (Static Analysis, Metrics Test Automation (Unit & Integration Tests) 16

Slide 17

Slide 17 text

DevOps do Test First Unit Tests Test the smallest possible components in an artifical environment. System Tests Test the entire application in a real(istic) environment together with other applications. 17

Slide 18

Slide 18 text

UNTESTED BROKEN 18

Slide 19

Slide 19 text

© Copyright 2013 Pivotal. All rights reserved. 19 A Foundation Based on Choice Runtime/Frameworks Buildpacks Service Brokers … and Custom Runtimes … and Custom Services Cloud Provider Interface (CPI) App Services Clouds … and Custom Clouds

Slide 20

Slide 20 text

Review: Pivotal Cloud Foundry Architecture 20 Pivotal CF Elastic Runtime PCF Operations Manager & BOSH Service Broker Marketplace Cloud Foundry API CI Services Data Services Others PCF Apps Manager Mobile Services Pivotal Network Apps Manager: to manage applications, service broker dashboards, usage reporting Service Marketplace: expose services in Platform marketplace for sharing with the developer community Ops Manager: exposes services in the marketplace for sharing with the developer community

Slide 21

Slide 21 text

Why Pivotal Cloud Foundry Services ▪ Operated ‘as a Service’ ▪ Configured and integrated to enable push button deployment. ▪ Full lifecycle management - software updates and patching ▪ Bind to apps through an easy-to-use interface ▪ Common view into access control and audit trails across a breadth of services Elastic Runtime Redis For PCF PCF Operations Manager MySQL for PCF RabbitM Q for PCF Elastic Runtime integrated into leading data services; all scaled and managed by PCF Ops Manager

Slide 22

Slide 22 text

Running Cloud Foundry Locally

Slide 23

Slide 23 text

Download: 
 network.pivotal.io/products/pcfdev cf login -a 
 api.local.pcfdev.io
 -skip-ssl-validation
 cf push #deploy app
 cf app #see details
 cf scale #scale
 cf ssh #troubleshoot First Experience

Slide 24

Slide 24 text

© Copyright 2015 Pivotal. All rights reserved. 24 How many microservices? ELEVEN

Slide 25

Slide 25 text

© Copyright 2015 Pivotal. All rights reserved. 25 “All teams will henceforth expose their data and functionality through service interfaces. Teams must communicate with each other through these interfaces. …There will be no other form of inter-process communication allowed: no direct linking, no direct reads of another team’s data store, no shared-memory model, no back-doors whatsoever. The only communication allowed is via service interface calls over the network. It doesn’t matter what technology they use. All service interfaces, without exception, must be designed from the ground up to be externalizable… That is to say, the team must plan and design to be able to expose the interface to developers in the outside world. No exceptions. Anyone who doesn’t do this will be fired. Thank you; have a nice day!“ Jeff Bezos CEO, Amazon Source: https://plus.google.com/+RipRowan/posts/eVeouesvaVX

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

© Copyright 2015 Pivotal. All rights reserved. 27 Creating a Distributed Monolith If you can’t deploy your services independently then they aren’t microservices. • Decouple. • Transform data (Strangler Pattern). • API First design • Consumer-driven contracts.

Slide 28

Slide 28 text

CUSTOM SERVICES IN PCF

Slide 29

Slide 29 text

3 options Custom PCF Tile User-Provided Service Broker • Service instance which have been provisioned outside of Cloud. Foundry. • Behave like other service instances once created. • Eliminate the need to hard code service instance endpoints. • A simple and consistent way to access services that may be running on top of Cloud Foundry, controlled by Cloud Foundry or running totally independently of Cloud Foundry. • 5 RESTful APIs • Expose services in the marketplace • Service instance managed inside Pivotal Cloud Foundry. • Most of the time uses a Service Broker. • Enterprise grade services. • Same experience as PCF Products

Slide 30

Slide 30 text

Service Broker • Integrating with externally hosted SaaS products. • Integrating with on-premise but external to PCF (i.e. Legacy database) • No on-premise deployable solution. • Comprehensible/Reliable API • Complex to automate with BOSH • Service API • Seamless Experience for developers • Treated as a product (maintenance, support, etc.) Use-cases Why When Official Service Brokers 1. App Direct 2. External PostGres 3. External Oracle 4. External MS-SQL 5. External RDS, SQS • Write a service broker that is deployed to PCF (as a VM or the runtime) • Integrate with the external service Service broker Full instructions can be found here http://docs.pivotal.io/pivotalcf/services/overview.html

Slide 31

Slide 31 text

Service Broker API /v2/catalog [GET] /v2/service_instances/:id [PUT] /v2/service_instances/:instance_id/service_bindings/:id [PUT] /v2/service_instances/:instance_id/service_bindings/:id [DELETE] /v2/service_instances/:id [DELETE]

Slide 32

Slide 32 text

Service broker Deployment & Registration Full instructions can be found here http://docs.pivotal.io/pivotalcf/services/managing-service-brokers.html • Make the service broker known to the Cloud Controller – cf create service-broker – Broker should ONLY allow access to those requestors it shared its credential with (Basic Auth) • Make ‘plans’ accessible to users in a specific org/ space – cf enable-service-access SERVICE [-p PLAN] [-o ORG] Admin creds/role is required • Entire service (service backend + broker) packaged and deployed by BOSH alongside Cloud Foundry, rest of the service deployed and maintained by other means • Broker (and optionally service) pushed as an application to Cloud Foundry user space Foundry • Entire service, including broker, deployed and maintained outside of Cloud Foundry by other means 1. Deployment models 2. Registration

Slide 33

Slide 33 text

© Copyright 2015 Pivotal. All rights reserved. Service Brokers 33 Service Brokers provide an interface for native and external 3rd party services. Service processes run on Service Nodes or with external as-a-service providers (e.g., email, database, messaging, etc.). How It Works: • Advertising service catalog • Makes create/delete/bind/unbind calls to service nodes • Requests inventory of existing instances and bindings from cloud controller for caching, orphan management • SaaS marketplace gateway Responsible For: query catalog: get a catalog of current services provision account: via SSO/Oauth 2.0 create service: use AppDirect APIs to start a service bind service: Bind a service to an app (set env variables)

Slide 34

Slide 34 text

© Copyright 2015 Pivotal. All rights reserved. 34 API Overview 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. 
 https://docs.cloudfoundry.org/services/api.html

Slide 35

Slide 35 text

Creating and Binding Service 35 DB Router Service credentials reserve resources obtain connection data CLI Cloud Controller Service Broker Data Service Runtime create service (HTTP) bind service (HTTP) create service (HTTP) bind service (HTTP)

Slide 36

Slide 36 text

© Copyright 2013 Pivotal. All rights reserved. 36 Services Broker: More than one way to consume services Application Resell As-a-Service ISV/Buildpack on PaaS Service Connector On-Prem Deploy (via BOSH)

Slide 37

Slide 37 text

© Copyright 2016 Pivotal. All rights reserved. Avoid Technical Debt Spring Boot + CF Service Brokers If you have to implement the same thing in every application, it should be provided by the platform as a Service.

Slide 38

Slide 38 text

© Copyright 2016 Pivotal. All rights reserved. “Operations is the secret sauce” http://radar.oreilly.com/2007/10/operations-is-a-competitive-ad.html

Slide 39

Slide 39 text

© Copyright 2016 Pivotal. All rights reserved. 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

Slide 40

Slide 40 text

© Copyright 2016 Pivotal. All rights reserved. Amazon S3 Service Broker • The demo for this presentation is going to create an Amazon S3 service broker. • 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

Slide 41

Slide 41 text

“Here is my source code
 Run it on the cloud for me
 I do not care how”

Slide 42

Slide 42 text

© Copyright 2015 Pivotal. All rights reserved. 42 I. Codebase II. Dependencies III. Configuration IV. Backing services V. Build, release, run VI. Process VII. Port binding VIII. Concurrency IX. Disposability X. Dev/Prod parity XI. Logs XII. Admin Process http://12factor.net 12 Factor Apps

Slide 43

Slide 43 text

© Copyright 2015 Pivotal. All rights reserved. 43 Backing Services https://12factor.net/backing-services

Slide 44

Slide 44 text

© Copyright 2015 Pivotal. All rights reserved. 44 Template Pattern • In the template method of this design pattern, one or more algorithm steps can be overridden by subclasses to allow differing behaviors while ensuring that the overarching algorithm is still followed - Wiki (Java) •“A template is a model that you use to create other documents.” - Open Office https://en.wikipedia.org/wiki/Template_method_pattern

Slide 45

Slide 45 text

© Copyright 2015 Pivotal. All rights reserved. 45 Resources • https://speakerdeck.com/sergiubodiu/service-brokers-deep- dive-singasug (Presentation) • https://github.com/sergiubodiu/service-brokers-deep-dive (Github Code) • https://github.com/spring-cloud/spring-cloud-cloudfoundry- service-broker (Spring Template)

Slide 46

Slide 46 text

Transform How the World Builds
 SOFTWARE Sergiu Bodiu Platform Architecture @sergiu_bodiu