Goal
provides libraries to apply common patterns needed in distributed applications
Distributed /versioned /centralized configuration management
service discovery and service registration
Load Balancing
Service to Service calls
circuit Breakers
Routing
Spring Cloud -
Spring cloud projects are all based on spring boot mainly for
Dependency management
Application Context startup process modified
Application Configuration?
➤Applications has connections to resources like database ,messaging queue ,email server and also they need to call other applications like they needed to call some web services etc.
➤usually we use external configuration to adjust this software behavior.
➤ Configuration files in common file system
-- not work in cloud based enviorenment
➤ use environment variable
needed to manage variable individual level and manage duplicate.
➤Use cloud vendor specific solutions
-Coupling would be tight and it is for specific environment.
Challenges-
➤ Microservices -> large no of dependent services ( lot of manual work )
➤ Dynamic update
➤ version control
Desired Solution-
Platform/Cloud independent solution
Centralized
dynamic
controllable
Solution-⌬
➤Spring Cloud Config - Provides centralize,externalize ,secured ,easy source of application configuration
➤Spring Cloud Bus- provide simplest way to notify clients to config changes
➤Spring Cloud Netflix Eureka
- Service Discovery - Allows applications to register themselves as clients
Spring Cloud Config
Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system.
➤Centralized server:
central place to manage external properties for applications across all environments. '
for serving configuration information ,configuration is backed by source control (git,flat file ....)
➤Client Application: connects over HTTP and retrieve their configuration setting
Spring Cloud Config Server-
include minimal dependencies in your pom or gradle
provides libraries to apply common patterns needed in distributed applications
Distributed /versioned /centralized configuration management
service discovery and service registration
Load Balancing
Service to Service calls
circuit Breakers
Routing
Spring Cloud -
Spring cloud projects are all based on spring boot mainly for
Dependency management
Application Context startup process modified
Application Configuration?
➤Applications has connections to resources like database ,messaging queue ,email server and also they need to call other applications like they needed to call some web services etc.
➤usually we use external configuration to adjust this software behavior.
- to find resources where they are located
- how to connect with db
what are different configuration options?
➤you can externalize the configuration from your code put it in configuration files with application and package them within application
however if you have to do any kind of change in your configuration then you needed to rebuild the code and restart the server.
➤ Configuration files in common file system
-- not work in cloud based enviorenment
➤ use environment variable
needed to manage variable individual level and manage duplicate.
➤Use cloud vendor specific solutions
-Coupling would be tight and it is for specific environment.
Challenges-
➤ Microservices -> large no of dependent services ( lot of manual work )
➤ Dynamic update
➤ version control
Desired Solution-
Platform/Cloud independent solution
Centralized
dynamic
controllable
Solution-⌬
➤Spring Cloud Config - Provides centralize,externalize ,secured ,easy source of application configuration
➤Spring Cloud Bus- provide simplest way to notify clients to config changes
➤Spring Cloud Netflix Eureka
- Service Discovery - Allows applications to register themselves as clients
Spring Cloud Config
Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system.
➤Centralized server:
central place to manage external properties for applications across all environments. '
for serving configuration information ,configuration is backed by source control (git,flat file ....)
➤Client Application: connects over HTTP and retrieve their configuration setting
Spring Cloud Config Server-
include minimal dependencies in your pom or gradle
- spring cloud starter parent
- spring cloud config server
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
application.yml
---
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: git uri.....(put your configuration here)
#username:
#password:
search-paths:
- 'station*'
Application Class
@SpringBootApplication
@EnableConfigServer
public class SpringcloudConfigserverApplication {
public static void main(String[] args) {
SpringApplication.run(SpringcloudConfigserverApplication.class, args);
}
}
Spring Cloud Client Application
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.springcloud.client.demo</groupId>
<artifactId>springcloud-configclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springcloud-configclient</name>
<description>testing spring cloud config server</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
bootstrap.properties
spring.profiles.active=qa
spring.cloud.config.uri=http://localhost:8888
No comments:
Post a Comment
Note: only a member of this blog may post a comment.