Pivotal spring boot-cloud workshop

41
1 © 2015 Pivotal Software, Inc. All rights reserved. Spring Boot and Spring Cloud Dev101 - Workshop Sufyaan Kazi (@sufyaan_kazi) & Sara Mitchell Manager, Field Engineering UK & I

Transcript of Pivotal spring boot-cloud workshop

Page 1: Pivotal   spring boot-cloud workshop

1 © 2015 Pivotal Software, Inc. All rights reserved. 1 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Boot and Spring Cloud Dev101 - Workshop

Sufyaan Kazi (@sufyaan_kazi) & Sara Mitchell Manager, Field Engineering UK & I

Page 2: Pivotal   spring boot-cloud workshop

2 © 2015 Pivotal Software, Inc. All rights reserved.

Powering Digital Transformation Pivotal enables enterprises to provide

modern software-driven experiences for their customers and workforces.

Page 3: Pivotal   spring boot-cloud workshop

3 © 2015 Pivotal Software, Inc. All rights reserved.

Modern Approach for Digital Business

AGILE PRODUCT DEVELOPMENT

Agile practices and collaboration for product and culture transformation

•  World class application development services

•  Proven transformational methodology

BIG DATA Modern, open, highly parallelized platform

•  Hadoop, in-memory, and database software

•  Industries most complete big data analytics offering

CLOUD NATIVE PLATFORM Modern, open, highly

automated cloud platform

•  Platform-as-a-Service (PaaS) software with multi-cloud support

•  Record-breaking sales growth and adoption

Page 4: Pivotal   spring boot-cloud workshop

4 © 2015 Pivotal Software, Inc. All rights reserved.

How We Deliver Transformation

Build product with us in our office

Undergo leadership training

Take back what you’ve learned

Page 5: Pivotal   spring boot-cloud workshop

5 © 2015 Pivotal Software, Inc. All rights reserved. 5

Cloud Native

DevOps Continuous Delivery

Containers Micro services

Page 6: Pivotal   spring boot-cloud workshop

6 © 2015 Pivotal Software, Inc. All rights reserved.

Microservices are key for CLOUD NATIVE JAVA

Application Framework

Infrastructure Automation

Platform Runtime

Language framework for microservice-based architectures including components for service discovery, metrics and circuit breakers.

Application container runtime with attachable backing services, automated CI/CD, routing, health management and logging.

A single deployment API for provisioning for bit-for-bit, consistent, self-healing deployments across any private or public cloud.

Dev

Dev Ops

Ops

Spring Cloud

Spring Boot

BOSH

Contract: 12 Factor Application

Contract: BOSH Release

Page 7: Pivotal   spring boot-cloud workshop

7 © 2015 Pivotal Software, Inc. All rights reserved. 7

Spring Boot

Dynamic language productivity with maturity of enterprise Java Cloud Native: Direct support for Microservices, NetflixOSS++ Fully automated app server configuration and deployment Production ready Ops metrics out of the box, with a switch

Page 8: Pivotal   spring boot-cloud workshop

8 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Boot Capabilities

8

•  Quick start project generation •  Automatic project dependency mapping •  Configuration drift prevention •  Conditional configuration with profiles •  Developer productivity tooling •  Auto configuration •  Monitoring and management endpoints •  Micro-services friendly

Page 9: Pivotal   spring boot-cloud workshop

9 © 2015 Pivotal Software, Inc. All rights reserved.

Page 10: Pivotal   spring boot-cloud workshop

10 © 2015 Pivotal Software, Inc. All rights reserved. 10

Spring Cloud

Spring Boot Dev

Spring Boot From 0 to app in < 5 min

Enterprise Java with dynamic

language productivity

Spring Cloud Designed for fragile infrastructure in

partnership with Netflix

Java Microservice Framework 100% Spring Boot enabled

Application Framework

Page 11: Pivotal   spring boot-cloud workshop

11 © 2015 Pivotal Software, Inc. All rights reserved.

DEMO!

Page 12: Pivotal   spring boot-cloud workshop

12 © 2015 Pivotal Software, Inc. All rights reserved.

Enhanced Application with Spring Boot package hello;import java.util.Arrays;

import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.ApplicationContext;

@SpringBootApplicationpublic class Application {

public static void main(String[] args) { SpringApplication.run(HelloSpringBootApplication.class, args); }

}

MAGIC!!

•  Tags the class as a source for Spring Beans

•  Asks Boot to automatically add beans based on classpath

•  Tell Spring to look for other components, configs etc. in the same package

Page 13: Pivotal   spring boot-cloud workshop

13 © 2015 Pivotal Software, Inc. All rights reserved.

Simple Spring MVC with Annotations package hello;

import org.springframework.web.bind.annotation.RestController;import org.springframework.web.bind.annotation.RequestMapping;

@RestControllerpublic class HelloController {

@RequestMapping("/") public String index() { return "Greetings from Spring Boot!"; }

}

Ready for SpringMVC to handle Web requests

Maps ‘/’ to this method

Page 14: Pivotal   spring boot-cloud workshop

14 © 2015 Pivotal Software, Inc. All rights reserved.

TO THE LABS!!

Page 15: Pivotal   spring boot-cloud workshop

15 © 2015 Pivotal Software, Inc. All rights reserved.

http://bit.ly/1SryunD

Page 16: Pivotal   spring boot-cloud workshop

16 © 2015 Pivotal Software, Inc. All rights reserved.

SKIP STRAIGHT TO LAB 3

Page 17: Pivotal   spring boot-cloud workshop

17 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Boot Actuator Actuator, production ready features exposed as endpoints. There are many built-in endpoints but this can be extended.

Page 18: Pivotal   spring boot-cloud workshop

18 © Copyright 2013 Pivotal. All rights reserved.

Elastic Runtime High Level Architecture

•  Turnkey, fully automated Platform-as-a-Service

•  Scalable runtime environment, extensible to most modern frameworks and languages running on Linux

•  Instant expansion or upgrade with no downtime

•  Deploy, scale and manage applications with bindable services using simplified semantics and APIs

Pivotal CF Elastic Runtime

DynamicRouter

OAuth2.0Server(UAA)

CELL

Garden

BuildPacks

LoginServer

CC&CCBridge

BlobStore

BBS/etcd

SysLog

ServiceBrokers

Collector AppLog

ROUTING

AUTHENTICATION

APPLIFECYCLE

APPSTORAGE&EXECUTION

MESSAGING

METRICS&LOGGING

Pivotal CF OpsManager/BOSH

BBS Converger

VMware OpenStack AWS Azure Google

Page 19: Pivotal   spring boot-cloud workshop

19 © Copyright 2013 Pivotal. All rights reserved.

Container Scheduling

Application Framework

Services Platform Runtime

Routing Database Configuration Service Discovery

Big Data

Object Storage

Mobile

Build CI

User Provided Logging & Metrics Messaging

Circuit Breakers 12 Factor Apps RESTful Services Microservices

.NET Spring Boot Node.js Ruby on Rails

Operations Zero Downtime Deployments

Failover & Recovery Scaling Security

Patching Platform

Upgrades

Infrastructure OpenStack Amazon VMware Azure

Page 20: Pivotal   spring boot-cloud workshop

20 © 2015 Pivotal Software, Inc. All rights reserved.

1.  Upload app bits and metadata

push app

Router

2.  Create and bind services

3.  Stage application

4.  Deploy application

5.  Manage application health

Blobstore DB

Service Broker Node(s) Cloud Controller

DEA DEA

DEA CELL

+ app MD

Service credentials

Cloud Controller Bridge

Auctioneer

BBS

Overview: Deploying App to Cloud Foundry Runtime

+ =

Page 21: Pivotal   spring boot-cloud workshop

21 © 2015 Pivotal Software, Inc. All rights reserved.

Stage an Application Ro

uter

CloudFoundryElasQcRunQme

Blobstore DB

CELL Detect Compile Upload No Yes

System Buildpacks

Cloud Controller

Service credentials creds

Cloud Controller Bridge

Task

+ =

Page 22: Pivotal   spring boot-cloud workshop

22 © 2015 Pivotal Software, Inc. All rights reserved.

Rou

ter

Cloud Controller Cloud Controller Bridge

Auctioneer BBS

CELL Rep

Executor

CELL Rep

Executor

CELL Rep

Executor

ACCESS APP

Deploying an Application

Page 23: Pivotal   spring boot-cloud workshop

23 © 2015 Pivotal Software, Inc. All rights reserved.

Containers Pre-date the Docker Hype

Google started Linux container effort “Control

Groups”

Added to the Linux Kernel in

2007

Cloud Foundry uses Linux container

technology - “Warden

containers” early 2012

Docker is like github for container images

Docker joins Cloud Foundry

Foundation

Google, MSFT, IBM working on orchestration of multiple Docker

containers

2006 2014

Cloud Foundry has been using container technology pre-Docker

2012

Page 24: Pivotal   spring boot-cloud workshop

24 © 2015 Pivotal Software, Inc. All rights reserved.

BUILD PACKS

Page 25: Pivotal   spring boot-cloud workshop

25 © 2015 Pivotal Software, Inc. All rights reserved.

Platform provides standard Buildpack for runtime*

Platform provides fixed OS container image

Developer brings app

Developer brings runtime Docker image

Developer brings Docker OS image

Developer brings app

Buildpacks Docker

* Devs may also provide their own buildpacks

Platform provides fixed host OS Kernel

Platform provides fixed host OS Kernel

Application Container

Standardization or Customization is Your Choice

AND

Page 26: Pivotal   spring boot-cloud workshop

26 © 2015 Pivotal Software, Inc. All rights reserved.

What does it mean to have a “Platform” ? The minimum features needed…

PaaS

Routing

Load Balancing

Service Brokers

Infrastructure automation

Log aggregation

Health monitoring &

recovery

Immutable artifact

repository

Page 27: Pivotal   spring boot-cloud workshop

27 © 2015 Pivotal Software, Inc. All rights reserved.

AND RELAX …

Page 28: Pivotal   spring boot-cloud workshop

28 © 2015 Pivotal Software, Inc. All rights reserved.

GIVE ME MORE…

Page 29: Pivotal   spring boot-cloud workshop

LocalProfile

@RepositoryRestResource @EnQty

CityMicroservice-@SpringBootApplicaQon

CloudProfile

SpringBoot&CloudMagic!

In-MemoryDB

SpringBootMagic!

Page 30: Pivotal   spring boot-cloud workshop
Page 31: Pivotal   spring boot-cloud workshop

31 © 2015 Pivotal Software, Inc. All rights reserved.

NETFLIX…

Page 32: Pivotal   spring boot-cloud workshop

32 © 2015 Pivotal Software, Inc. All rights reserved.

Spring Cloud Services for Pivotal Cloud Foundry

•  Install

•  Config

•  Manage

•  Secure Spring Cloud Services

Config Server

Service Registry

Circuit Breaker Dashboard

Page 33: Pivotal   spring boot-cloud workshop

33 © 2015 Pivotal Software, Inc. All rights reserved.

Config Server

Page 34: Pivotal   spring boot-cloud workshop

34 © 2015 Pivotal Software, Inc. All rights reserved.

Service Registration/Discovery @SpringBootApplication @EnableCircuitBreaker @EnableDiscoveryClient public class CustomerApp extends RepositoryRestMvcConfiguration {

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration

config) { config.exposeIdsFor(Customer.class); }

public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); }

}

Page 35: Pivotal   spring boot-cloud workshop

35 © 2015 Pivotal Software, Inc. All rights reserved.

Service Registration/Discovery

Page 36: Pivotal   spring boot-cloud workshop

36 © 2015 Pivotal Software, Inc. All rights reserved.

Service Registration/Discovery @SpringBootApplication @EnableCircuitBreaker @EnableDiscoveryClient public class CustomerApp extends RepositoryRestMvcConfiguration {

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration

config) { config.exposeIdsFor(Customer.class); }

public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); }

}

Page 37: Pivotal   spring boot-cloud workshop

37 © 2015 Pivotal Software, Inc. All rights reserved.

Fault Tolerance – Circuit Breakers

Page 38: Pivotal   spring boot-cloud workshop

38 © 2015 Pivotal Software, Inc. All rights reserved.

Fault Tolerance – Circuit Breakers @SpringBootApplication @EnableCircuitBreaker @EnableDiscoveryClient public class CustomerApp extends RepositoryRestMvcConfiguration {

@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration

config) { config.exposeIdsFor(Customer.class); }

public static void main(String[] args) { SpringApplication.run(CustomerApp.class, args); }

}

Page 39: Pivotal   spring boot-cloud workshop

39 © 2015 Pivotal Software, Inc. All rights reserved.

@HystrixCommand(fallbackMethod = "defaultLink") public Link getStoresByLocationLink(Map<String, Object> parameters) { URI storesUri = URI.create(uri); try {

ServiceInstance instance = loadBalancer.choose("stores"); storesUri = URI.create(String.format("http://%s:%s",

instance.getHost(), instance.getPort())); } catch (RuntimeException e) { // Eureka not available }

Traverson traverson = new Traverson(storesUri, MediaTypes.HAL_JSON); Link link = traverson.follow("stores", "search", "by-location") .withTemplateParameters(parameters).asLink();

return link; }

Enabling a Circuit Breaker

Client-Side Load Balancing

Page 40: Pivotal   spring boot-cloud workshop

40 © 2015 Pivotal Software, Inc. All rights reserved.

Anatomy of a cloud native framework

Application coordination boilerplate patterns

Application configuration boilerplate patterns

Enterprise application boilerplate patterns

Runtime Platform, Infrastructure Automation boilerplate patterns (provision, deploy, secure, log, data services, etc.)

Clo

ud

Des

ktop

Spring Boot

Spring IO

Pivotal Cloud Foundry

Spring Cloud

+ BOSH

Page 41: Pivotal   spring boot-cloud workshop