introduction to spring cloud oss - denver cloud foundry meetup

16
TECHNOLOGY SOLUTIONS DELIVERED Intro to Spring Cloud OSS Denver Cloud Foundry Meetup August 26, 2016 Josh Ghiloni (@joshghiloni)

Upload: josh-ghiloni

Post on 21-Feb-2017

292 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

TECHNOLOGY SOLUTIONS DELIVERED

Intro to Spring Cloud OSSDenver Cloud Foundry Meetup

August 26, 2016Josh Ghiloni (@joshghiloni)

Page 2: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Agenda•Spring Cloud Origins•Why Spring Cloud?•External Configuration with Spring Cloud Config Server•Runtime Service Discovery with Eureka•Using Hystrix to Fail Gracefully•Demo!

Page 3: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Spring Cloud Origins

Page 4: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Why Spring Cloud?

Microservice architectures are complex!• They need to have their config stored in the environment, not in code• Microservices are loosely coupled – They need to discover and be discoverable• They are not necessarily colocated – Inter-service communication needs to be

fault-tolerant

Netflix is a microservice architecture … they (probably) didn't build all this just because they were bored

Page 5: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

External Configuration with Spring Cloud Config Server

• Follow 12 Factor app development!

• Configuration stored in source control

• Extensible (store your config in a DB or LDAP or on punch cards)

• Securable (secure with whatever scheme you choose)

• Data can be stored encrypted at rest and decrypted on the fly (requires Unlimited JCE policy in Java buildpack)

@SpringBootApplication@EnableDiscoveryClient@EnableConfigServerpublic class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run( ConfigServerApplication.class, args ); }}

Page 6: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Runtime Service Discovery with Eureka•Register and discover services at runtime

•Registrations stored in memory

•Simple dashboard available•Spring Boot autoconfiguration for self-registration

•Can be used to look up external config servers automatically

@SpringBootApplication@EnableEurekaServerpublic class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run( EurekaServerApplication.class, args ); }}

Page 7: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

High Availability with Eureka

eureka-0 eureka-1 eureka-2 eureka-n

Route eureka

Page 8: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Using Hystrix to Fail Gracefully

source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html

Page 9: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Using Hystrix to Fail Gracefully

source: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html

Page 10: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Including Spring Cloud in your Application@SpringBootApplication@EnableCircuitBreaker // for Hystrix@EnableDiscoveryClient // for Eureka@RestControllerpublic class MySpringCloudApplication { public static void main(String[] args) { SpringApplication.run(MySpringCloudApplication.class, args); } @RequestMapping("/") public String helloWorld() { return "Hello, World!"; }}

or…

Page 11: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Including Spring Cloud in your Application

@SpringCloudApplication@RestControllerpublic class MySpringCloudApplication { public static void main(String[] args) { SpringApplication.run(MySpringCloudApplication.class, args); } @RequestMapping("/") public String helloWorld() { return "Hello, World!"; }}

Page 12: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

More Spring Cloud Integrations•Ribbon (Netflix) – Client Side Load Balancing•Zuul (Netflix) – Dynamic Routing•Feign (Netflix) – Declarative REST Client•Archaius (Netflix) – Client side configuration•Security – Single Sign on via OAuth2•Consul – Service Discovery•Zookeeper – Service Discovery

Page 13: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Demo!

Page 14: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Questions?

Page 15: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

ReferencesTwelve Factor Apps: http://12factor.netMicroservice Prereqs: http://martinfowler.com/bliki/MicroservicePrerequisites.html Spring Boot: http://projects.spring.io/spring-boot/Spring Cloud: http://projects.spring.io/spring-cloud/ Netflix OSS: http://netflix.github.io/ Java Buildpack with Unlimited JCE: https://github.com/jghiloni/java-buildpack Source for this Demo: https://github.com/ECSTeam/spring-cloud-demo

Page 16: Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup

Thank You!