Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- intelij devtools
- sidecar patern
- MySQL
- spring boot http client
- jpa auto increment
- msa 4.0
- Istio
- kubernates
- redis ha
- java static resources
- Service Mesh
- spring cloud api gateway
- spring boot 2.0 ssl
- tracing tool
- spring cloud zuul
- spring boot ssl
- Spring boot
- spring cloud load balancer
- Spring Cloud Config
- spring boot ssl verify skip
- high availabillty
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <rect x="10" y="10" height="100" width="100" style="stroke:#ff0000; fill: #0000ff"/> </svg>
- redis cluster
- Spring Cloud Bus
- intelij spring boot devtools
- spring boot hot swapping
- Distributed Tracing System
- <iframe src="http://erea.tistory.com/attachment/cfile21.uf@997995485B2F785A3292EE.svg"></iframe>
- sidecar
- spring boot jks
Archives
- Today
- Total
erea
spring cloud config server 본문
Overview
Spring Cloud Config는 분산 시스템에서 외부화 된 구성에 대한 서버 및 클라이언트 측 지원을 제공합니다. 구성 서버를 사용하면 모든 환경에서 응용 프로그램의 외부 속성을 중앙에서 관리 할 수 있습니다. 클라이언트와 서버의 개념은 Spring Environment과 동일하게 매핑됩니다.PropertySource추상화를 통해 Spring 애플리케이션에 매우 잘 어울리지만 모든 언어로 실행되는 모든 애플리케이션에서 사용할 수 있습니다. 애플리케이션이 개발 파이프 라인을 통해 개발에서 테스트 및 프로덕션 환경으로 이동하면 해당 환경 간의 구성을 관리 할 수 있으며 마이그레이션 할 때 실행하는 데 필요한 모든 기능을 애플리케이션에 적용 할 수 있습니다. 서버 스토리지 백엔드의 기본 구현은 git을 사용하므로 구성 환경의 레이블링 된 버전을 쉽게 지원할뿐만 아니라 컨텐츠 관리를위한 다양한 툴링에 액세스 할 수 있습니다. 대체 구현을 추가하고 Spring 구성으로 플러그인을 쉽게 삽입 할 수 있습니다.
정리하자면 원격지에 config server를 두고 refresh 하여 서버 재구동없이 간편하게 프로터리를 관리할수 있다.
물론 프로덕션 환경에서는 이중화를 하거나 git으로 관리하는것을 추천
설치
config server
본 게시물은 git 연동대신 native 서버로 진행하겠습니다.
application.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | server: port: 8888 spring: profiles: active: native application: name: front-service cloud: config: server: native : searchLocations: classpath:/configs/ endpoints: restart: enabled: true |
build.gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | buildscript { ext { springBootVersion = '2.0.3.RELEASE' } repositories { mavenCentral() } dependencies { classpath( "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" ) } } apply plugin: 'java' apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } ext { springCloudVersion = 'Finchley.RELEASE' } dependencies { compile( 'org.springframework.cloud:spring-cloud-config-server' ) testCompile( 'org.springframework.boot:spring-boot-starter-test' ) } dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } |
resources/configs/test-service.yml
1 2 3 4 5 6 | spring: datasource: url: jdbc:mariadb: //##:3306 username: ## password: ## driver- class -name: org.mariadb.jdbc.Driver |
resources/configs/test-service-dev.yml
1 2 3 4 5 6 | spring: datasource: url: jdbc:mariadb: //##:3308 username: ## password: ## driver- class -name: org.mariadb.jdbc.Driver |
application.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @EnableConfigServer @SpringBootApplication @RestController public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication. class , args); } @RequestMapping ( "/" ) public String home() { System.out.println( "called root URI!!!" ); return "config-service" ; } } |
config client
resources/bootstrap.yml
1 2 3 4 5 6 7 | spring: application: name: test-service cloud: config: uri: http: //localhost:8888 fail-fast: true |
client서버에 bootstrap.yml 파일에 넣는 이유는 bootstrap이 application이 구동할떄 제일먼저 읽는 컨피그 파일이기때문이다
(application.yml 보다 먼저)
또한 fail-fast 플래그를 켜놓으면 컨피그서버가 구동하지않을때는 해당 클라이언트도 구동이 되지않게 할수 있다,.
spring profile 설정
spring.profiles.active=dev 로 하게 되면 test-service-dev.yml에 설정을 불러오게 된다,
기타
이상하게 기존 프로젝트의 적용해보았더니 컨피그 서버와 연결이 안되는 경우가 있는데 소스를 그대로 복사해서 새프로젝트의 세팅하니 잘연결이 되었다 --;
'dev > Spring Boot Cloud MicroService' 카테고리의 다른 글
spring cloud config server #3 (0) | 2018.07.10 |
---|---|
Zuul Proxy (0) | 2018.07.03 |
Eureka Server (0) | 2018.07.02 |
spring boot with Netflix Oss (0) | 2018.07.02 |