Spring Cloud

Spring Cloud Bootstrap (config, discover, gateway, services)

Spring Cloud is a framework for building robust cloud applications.

Applications that run with microservices architecture aim to simplify development, deployment, and maintenance. The decomposed nature of the application allows developers to focus on one problem at a time. Improvements can be introduced without impacting other parts of a system.

On the other hand, different challenges arise when we take on a microservice approach:

  • Externalizing configuration so that is flexible and does not require rebuild of the service on change
  • Service discovery
  • Hiding complexity of services deployed on different hosts

Config Server

(spring-cloud-starter-config, spring-cloud-config-server)
(@SpringBootApplication
@EnableConfigServer)

To solve this, we will consolidate all of our configuration into a single Git repository and connect that to one application that manages a configuration for all our applications.

Discovery

(spring-cloud-starter-config, spring-cloud-starter-eureka-server)
(@SpringBootApplication
@EnableEurekaServer)

Ee need a way for all of our servers to be able to find each other. We will solve this problem by setting the Eureka discovery server up. Since our applications could be running on any ip/port combination we need a central address registry that can serve as an application address lookup.

Gateway

(spring-cloud-starter-config, spring-cloud-starter-zuul, spring-cloud-starter-eureka)
(@SpringBootApplication
@EnableZuulProxy
@EnableEurekaClient)

Resolves how the clients access all of our applications.

If we leave everything in a distributed system, then we will have to manage complex CORS headers to allow cross-origin requests on clients.

Services

(spring-boot-starter-web, spring-cloud-starter-config, spring-cloud-starter-eureka ) (@SpringBootApplication
@EnableEurekaClient
@RestController)