Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Service Brokers Deep Dive Singasug

sergiubodiu
September 10, 2016

Service Brokers Deep Dive Singasug

Almost all applications depend on some external services like a database or third party components. In traditional development, we bind those components to an application using property files and store it outside the deployable, so that it can be modified whenever required without affecting the running application code.

Cloud Foundry therefore uses service brokers, through which developers can provision and bind a particular service to an application. Service brokers can be used to define the relationship between the application and services like databases. This permits loose coupling between an app and a service.

Demo:
CF Service Broker Integration - How to build an external service broker

The sample is a Spring Boot application, this project has been configured to bind to an Amazon S3 Service Broker instance on Cloud Foundry. To deploy this application to Cloud Foundry and use Amazon S3 as an auto-configured service binding.

Presenter:
Sergiu Bodiu is responsible for helping the region’s most strategic customers successfully implement technology and process for cloud and “3rd Platform” services. He is very passionate about open source and is a key contributor to the Spring community. More recently Sergiu has been focusing on platform-as-a-service for the cloud generation of apps whereby he has played a lead role in Asia Pacific and Japan in bringing Pivotal Cloud Foundry to market.

sergiubodiu

September 10, 2016
Tweet

More Decks by sergiubodiu

Other Decks in Technology

Transcript

  1. How hard it is to make changes to an App

    How often can I deploy that App
  2. © 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/
  3. 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
  4. That just leads to… Photo credit Viacom Entertainment Group Chopping

    up or rebuilding the platform in the cloud will be your initial INSTINCT
  5. • How to fix my legacy System? • How to

    fix my culture to Innovate?
  6. © 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 .
  7. © 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
  8. © 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.
  9. 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
  10. 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
  11. 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
  12. 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
  13. © 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
  14. 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
  15. 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
  16. Download: 
 network.pivotal.io/products/pcfdev cf login -a 
 api.local.pcfdev.io
 -skip-ssl-validation
 cf

    push <app> #deploy app
 cf app <app> #see details
 cf scale <app> #scale
 cf ssh <app> #troubleshoot First Experience
  17. © 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
  18. © 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.
  19. 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
  20. 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
  21. 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 name> <username> <password> <broker base URI> – 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
  22. © 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)
  23. © 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
  24. 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)
  25. © 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)
  26. © 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.
  27. © Copyright 2016 Pivotal. All rights reserved. “Operations is the

    secret sauce” http://radar.oreilly.com/2007/10/operations-is-a-competitive-ad.html
  28. © 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
  29. © 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
  30. “Here is my source code
 Run it on the cloud

    for me
 I do not care how”
  31. © 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
  32. © 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
  33. © 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)