Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cloud Native Java with Spring Cloud Services

1,381 views

Published on

SpringOne Platform 2016
Speakers: Craig Walls; Spring Social Lead, Pivotal. Roy Clarkson; Spring Mobile Lead, Pivotal.


Developing cloud native applications presents several challenges. How do microservices discover each other? How do you configure them? How can you make them resilient to failure? How can you monitor the health of each microservice?

Spring Cloud addresses all of these concerns. Even so, you still must explicitly develop your own discovery server, configuration server, and circuit breaker dashboard for monitoring the circuit breakers in each microservice.

Spring Cloud Services for Pivotal Cloud Foundry picks up where Spring Cloud leaves off, offering a discovery server, configuration server, and Hystrix dashboard as services that can be bound to applications deployed in Pivotal Cloud Foundry, leaving you to focus on developing the services that drive your application. In this talk, we will introduce the capabilities provided by Spring Cloud Services and demonstrate how it makes simple work of deploying cloud native applications to Cloud Foundry.

Published in: Technology

Cloud Native Java with Spring Cloud Services

  1. 1. 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/ Cloud Native Java with Spring Cloud Services Roy Clarkson Craig Walls @royclarkson @habuma
  2. 2. 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/ + 2 = ?
  3. 3. 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/ 3
  4. 4. 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/ 4
  5. 5. 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/ Spring Cloud Demo 5
  6. 6. 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/ I know Kung Fu • Eureka Server (Spring Cloud Netflix) • Config Server (Spring Cloud Config) • Hystrix Dashboard (Spring Cloud Netflix) • App Service • App UI 6
  7. 7. 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/ 7 Config Server Service Registry Circuit Breaker Dashboard ease of use security reliability
  8. 8. 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/ Create a Spring Cloud server 8 1. cf create-service 1. create a Spring Boot app 2. add Spring Cloud starters 3. add @EnableXxxxServer 4. add configuration 5. add security 6. deploy and manage
  9. 9. 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/ Create a Spring Cloud client application 9 1. create a Spring Boot app 2. add Spring Cloud Services starters 3. cf bind-service 1. create a Spring Boot app 2. add Spring Cloud starters 3. add configuration • Eureka-first or config-first bootstrapping? 4. add security
  10. 10. 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/ Secure access 10 Services are secured with OAuth2 OAuth2 credentials are exposed via service bindings Spring Cloud Services App Identity Server
  11. 11. 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/ Reliability 11 High availability and health management are provided by the platform
  12. 12. 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/ Service Brokers 12 Service brokers extend Cloud Foundry to provide resources that can be consumed by applications http://docs.cloudfoundry.org/services/ Cloud Foundry Service Broker provision instance get catalog delete binding delete instance create binding
  13. 13. 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/ 13
  14. 14. 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/ Spring Cloud Services Broker 14 Cloud Foundry Broker App provision instance get catalog create binding delete binding delete instance Worker App RabbitMQ create, delete, configure app and service instances
  15. 15. 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/ SCS is built on Spring Projects Spring Boot Spring Cloud Netflix Spring Cloud Config Server Spring Cloud Connectors 15 Spring Security Spring Security OAuth2 Spring Data JPA Spring AMQP Spring Boot CF Service Broker Cloud Foundry Java Client
  16. 16. 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/ Config Server 16
  17. 17. 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/ Overview Service • deploys a Spring Cloud Config server for each service instance provisioned • git backend • search paths within config repo • basic authentication to repo Security • only bound applications are able to see configuration Client Applications • starter automatically adds a property source configured for the config server 17
  18. 18. 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/ Configuration Server flow 181818
  19. 19. 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/ Dependencies 19 <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-config-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-client</artifactId> </dependency> Spring Cloud: Spring Cloud Services:
  20. 20. 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/ Service Registry 20
  21. 21. 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/ Overview Service • deploys a Spring Cloud Netflix Eureka server for each service instance provisioned Security • only the application that originally creates a registration is allowed to update or remove that registration • prevents Man In The Middle attacks against the Registry Client Applications • starter automatically configures a DiscoveryClient 21
  22. 22. 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/ Service Registry Flow 22 FortuneTellerService
  23. 23. 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/ Service Registry Flow 22 Where can I find FortuneTellerService?
  24. 24. 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/ Service Registry Flow 22 <application> <name>FortuneTellerService</name> <instance> <hostName>chip</hostName> <ipAddr>fortune-service.blue.springapps.io</ipAddr> … <application>
  25. 25. 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/ Service Registry Flow 22 Give me a random fortune GET http://fortune-service.blue.springapps.io/random
  26. 26. 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/ Dependencies 23 <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-service-registry</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> Spring Cloud: Spring Cloud Services: 23
  27. 27. 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/ Circuit Breaker Dashboard 24
  28. 28. 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/ Overview Service • deploys for each service instance provisioned: • Spring Cloud Netflix Hystrix dashboard • Spring Cloud Netflix Turbine server • Pivotal RabbitMQ service instance Client Applications • starter automatically configures a Turbine AMQP client 25
  29. 29. 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/ Circuit Breaker Dashboard Flow 26
  30. 30. 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/ Dependencies 27 <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-circuit-breaker</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency> Spring Cloud: Spring Cloud Services: 2727
  31. 31. 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/ 28 @Configuration public class CloudConfig extends CloudConnectorsConfig { @Bean @HystrixConnectionFactory public ConnectionFactory hystrixConnectionFactory() { return connectionFactory().hystrixConnectionFactory(); } } @Configuration public class RabbitConfig extends AbstractCloudConfig { @Bean @Primary public ConnectionFactory rabbitConnectionFactory() { return connectionFactory().rabbitConnectionFactory(); } }
  32. 32. 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/ Spring Cloud Services Dependencies <dependencyManagement> <dependencies> <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-dependencies</artifactId> <version>1.1.1.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Brixton.SR3</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> 29
  33. 33. 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/ Spring Cloud Services Dependencies 29 <dependencies> <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-config-client</artifactId> </dependency> <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-service-registry</artifactId> </dependency> <dependency> <groupId>io.pivotal.spring.cloud</groupId> <artifactId>spring-cloud-services-starter-circuit-breaker</artifactId> </dependency> </dependencies>
  34. 34. 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/ Enabling Spring Cloud @SpringBootApplication @EnableJpaRepositories @EnableDiscoveryClient public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } 30
  35. 35. 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/ Enabling Spring Cloud 30 @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class Application { @Bean @LoadBalanced public RestTemplate restTemplate() { return new RestTemplate(); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
  36. 36. 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/ Configuring Spring Cloud spring: application: name: fortunes 31 spring: application: name: ui
  37. 37. 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/ What’s new in SCS 1.1 • Spring Cloud Brixton Release Train and Spring Boot 1.3 Support • Asynchronous Service Provisioning and Zero Downtime Upgrades/Updates • Highly-Available Topologies for Config Server and Service Registry • Enhancements to the Config Server Git Backend 37 https://blog.pivotal.io/pivotal-cloud-foundry/products/spring- cloud-services-1-1-now-available
  38. 38. 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/ Spring Cloud Brixton and Spring Boot 1.3 // define a Ribbon enabled RestTemplate @Bean @LoadBalanced public RestTemplate restTemplate() { return new RestTemplate(); } 38 // inject the instance into your controller @Autowired RestTemplate rest;
  39. 39. 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/ Zero Downtime Upgrades & Updates • Upgrades to the SCS tile via Pivotal Cloud Foundry® Operations Manager • Upgrades to SCS service instances 39
  40. 40. 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/ 40
  41. 41. 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/ Highly Available Topologies • Config Servers are scaled horizontally via the Cloud Foundry API. • Service Registries are stateful components that replicate when clustered. The SCS service broker pushes the correct number of Eureka application instances and configures them for replication. • Changes to HA configurations are executed such that no application instances experience downtime. 41
  42. 42. 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/ Config Server Enhancements • Config Server now supports all features of the Spring Cloud Brixton Git backend, including multiple repositories, pattern matching, and placeholders. • Git repositories can now be accessed: • using self-signed SSL certificates for HTTPS • via an HTTP or HTTPS proxy server • via the Git or SSH protocols (in addition to HTTP/HTTPS). 42
  43. 43. 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/ Spring Cloud Services Demo 43
  44. 44. 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/ Safe Harbor Statement The following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 44
  45. 45. 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/ Learn More. Stay Connected. @springcentral spring.io/blog @pivotal pivotal.io/blog @pivotalcf http://engineering.pivotal.io

×