๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿ’Š Java & Kotlin & Spring/- spring framework +

Spring Cloud Config ์—์„œ ๋ณ€๊ฒฝ๋œ ์ •๋ณด๋ฅผ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ์ธ์Šคํ„ด์Šค์—์„œ Spring Boot Actuator ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฐ˜์˜ํ•˜๊ธฐ

by Wonit 2021. 4. 28.

 

ํ•ด๋‹น ๊ธ€์€ Spring Cloud Config์˜ name, profiles ๊ทธ๋ฆฌ๊ณ  Github ๋ฅผ ์—ฐ๋™ํ•ด์„œ ์„ค์ • ํŒŒ์ผ ๊ด€๋ฆฌํ•˜๊ธฐ์— ์˜์กดํ•˜๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค. ์‹ค์Šต ํ™˜๊ฒฝ์„ ๋”ฐ๋ผํ•˜์‹œ๋ ค๋ฉด ์ด์ „ ๊ธ€์— ๋‚˜์˜จ ์‹ค์Šต์„ ๋”ฐ๋ผํ•˜์‹œ๊ธธ ๊ถŒ๊ณ ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋ชฉ์ฐจ

  • ์„ค์ • ์ •๋ณด๋ฅผ ๋ฐ˜์˜ํ•˜๋Š” ์ด์œ 
  • Spring Boot Actuator๋ž€?
    • Spring Boot Actuator ์˜ ๊ธฐ๋Šฅ๊ณผ Endpoints
    • Config Refresh
  • Spring Boot Actuator ๋ฅผ ์ด์šฉํ•ด์„œ ๋ณ€๊ฒฝ ์ •๋ณด ๊ฐฑ์‹ ํ•˜๊ธฐ
    • User-Service์— Actuator ์˜์กด์„ฑ ์ถ”๊ฐ€ํ•˜๊ธฐ
    • refresh Endpoints ํ™œ์„ฑํ™”
    • ์›๊ฒฉ ์ €์žฅ์†Œ์— ์žˆ๋Š” yml ์„ค์ • ์ •๋ณด ๋ณ€๊ฒฝํ•˜๊ธฐ
    • refresh ํ•˜๊ธฐ

์„ค์ • ์ •๋ณด๋ฅผ ๋ฐ˜์˜ํ•˜๋Š” ์ด์œ 

์ง€๊ธˆ๊นŒ์ง€ Spring Cloud Config ์˜ ๋งŽ์€ ๊ธฐ๋Šฅ๋“ค์„ ์•Œ์•„๋ณด์•˜๊ณ  ์‹ค์Šตํ–ˆ๋‹ค.


ํ˜„์žฌ ์‹ค์Šต ๋‚ด์šฉ ์ค‘์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์ด ๋น ์กŒ๋‹ค.

 

๋ฐ”๋กœ ์„ค์ • ์ •๋ณด ๊ฐฑ์‹ ์ด๋‹ค.

 

Spring Boot Application ์ด ์ตœ์ดˆ์— ๋นŒ๋“œ๋  ๋•Œ bootstrap.yml ๊ณผ application.yml ํŒŒ์ผ์— ์žˆ๋Š” ์ •๋ณด๋ฅผ ์ด์šฉํ•ด์„œ Application์„ ๊ตฌ๋™์‹œํ‚จ๋‹ค.

 

ํ•˜์ง€๋งŒ ์ง€๊ธˆ ์ƒํ™ฉ์„ ๋ด๋ณด์ž.

 

์ตœ์ดˆ์— Application ์ด ๋นŒ๋“œ๋  ์‹œ์ ์—๋งŒ Config ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ์„ค์ • ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ  ํ•ด๋‹น ์ •๋ณด๋ฅผ ์ด์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค๋“ค์ด ๋‹ค์‹œ ๋นŒ๋“œ๋˜์ง€ ์•Š๋Š” ์ด์ƒ ์„ค์ • ์ •๋ณด๋Š” ๋ฐ˜์˜๋˜์ง€ ์•Š๋Š”๋‹ค.

 

๊ทธ๋Ÿผ ์ด ์ƒํ™ฉ์—์„œ ์–ด๋–ป๊ฒŒ ํ•ด์•ผํ• ๊นŒ?

 

๋‹ต์€ ๊ฐ„๋‹จํ•˜๋‹ค.

 

Spring Boot Application ์„ ๋‹ค์‹œ ๊ป๋‹ค๊ฐ€ ํ‚ค๋ฉด ๋œ๋‹ค.

 

ํ•˜์ง€๋งŒ ๋˜ ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค.

 

์šฐ๋ฆฌ์˜ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค๋“ค์€ ๋‹จ์ˆœํ•˜๊ฒŒ ๋Œ์•„๊ฐ€์ง€ ์•Š๋Š”๋‹ค. ์‹ค์ œ๋กœ๋Š” CI CD ํŒŒ์ดํ”„๋ผ์ธ๊ณผ ๋”๋ถˆ์–ด ๋‹ค์–‘ํ•œ ์ž๋™ํ™”์— ์—ฎ์—ฌ์žˆ์„ ํ…๋ฐ ์ˆ˜๋™์œผ๋กœ ์•ฑ์„ ๊ป๋‹ค๊ฐ€ ์ผฐ๋‹ค๊ฐ€ ํ•˜๋Š”๊ฒŒ ๊ณผ์—ฐ ์˜ณ์€ ๋ฐฉ๋ฒ•์ผ๊นŒ? ๋งŒ์•ฝ ์„œ๋น„์Šค๊ฐ€ 100 ๊ฐœ๋ผ๋ฉด ๋‹ค ๊ป๋‹ค ์ผฐ๋‹ค๋ฅผ ํ•ด์•ผํ• ๊นŒ?

 

์ด ๋•Œ ๋“ฑ์žฅํ•˜๋Š” ๊ฒƒ์ด ๋ฐ”๋กœ Spring Boot Actuator ์ด๋‹ค.

 

Spring Boot Actuator

Spring Boot includes a number of additional features to help you monitor and manage your application when you push it to production. You can choose to manage and monitor your application by using HTTP endpoints or with JMX. Auditing, health, and metrics gathering can also be automatically applied to your application.

Spring Boot Actuator ๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ Production ์œผ๋กœ ๋นŒ๋“œํ•  ๋•Œ ์ด๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๋‹ค.


HTTP End Point ๋ฅผ ํ†ตํ•ด์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ƒํƒœ ๊ด€๋ฆฌ ๋ฐ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

 

์‚ฌ์‹ค์ƒ Actuator ๋ฅผ ์ด์šฉํ•œ๋‹ค๊ณ  ํ•ด์„œ ์„ค์ • ์ •๋ณด๋ฅผ ๋ฐ˜์˜ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ป๋‹ค ํ‚ค๋Š” ๊ณผ์ •์„ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ๋Š ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค. ๋‹จ์ง€ ์กฐ๊ธˆ ๋” gracefully ํ•˜๊ฒŒ ์ด ๊ณผ์ •์„ ๋ฐ”๊พธ๋Š” ๊ฒƒ์ด๋‹ค. ํ•œ ๋ฒˆ ๊ป๋‹ค ํ‚ค๋Š”๋ฐ, ์–ผ๋งˆ๋‚˜ ์ด ๊ณผ์ •์ด ์šฐ์•„ํ•ด์ง€๋Š”์ง€ ์•„๋ž˜์—์„œ ์‹ค์Šตํ•ด๋ณด๋„๋ก ํ•˜์ž

Spring Boot Actuator ์˜ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ๊ณผ Endpoints

Spring Boot Actuator ๋Š” ํšจ๊ณผ์ ์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋ชจ๋‹ˆํ„ฐ๋ง๊ณผ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•ด์„œ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค.

 

์ด๋ฅผํ…Œ๋ฉด ํ•ด๋‹น application์˜ bean ๋“ค์ด ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉ๋˜๊ณ  ๊ด€๋ฆฌ๋˜๋Š”๊ฐ€ ํ˜น์€ ํ˜„์žฌ application์˜ ์ƒํƒœ(health)๋Š” ์–ด๋– ํ•œ๊ฐ€ ๊ทธ๋ฆฌ๊ณ  application์„ shutdown ํ˜น์€ ์žฌ๊ธฐ๋™ํ•˜๋Š” ๋ฐฉ๋ฒ•๋“ค ๊นŒ์ง€ ์•„์ฃผ ๋‹ค์–‘ํ•˜๋‹ค.

 

๋Œ€ํ‘œ์ ์ธ Endpoints ๋“ค์„ ๋ด๋ณด์ž.

  • shutdown
    • Lets the application be gracefully shutdown. Disabled by default.
  • metrics
    • Shows ‘metrics’ information for the current application.
  • beans
    • Displays a complete list of all the Spring beans in your application.
  • health
    • Shows application health information
  • httptrace
    • Displays HTTP trace information (by default, the last 100 HTTP request-response exchanges). Requires an HttpTraceRepository bean.

๋“ฑ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์ด ์กด์žฌํ•˜๋Š”๋ฐ, ์ž์„ธํ•œ ์‚ฌํ•ญ์€ Spring Boot Actuator ๊ณต์‹ ๋ฌธ์„œ ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์ด๋Ÿฐ ๋‹ค์–‘ํ•œ Endpoint ๋ฅผ ์ด์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” application.yml ์—์„œ management ์„ค์ • ๊ฐ’์„ ์กฐ์ž‘ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

์˜ˆ๋ฅผ ๋“ค์–ด์„œ health ๊ธฐ๋Šฅ๊ณผ beans ๊ธฐ๋Šฅ์„ ์ด์šฉํ•˜๋ ค ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž.

 

์šฐ์„  actuator ์˜ ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

 

implementation 'org.springframework.boot:spring-boot-starter-actuator'

 

๊ทธ๋Ÿผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด application.yml ์—์„œ endpoint ๋ฅผ include ํ•ด์ฃผ์ž.

 

management:
  endpoints:
    web:
      exposure:
        include: health, beans

๊ธฐ๋ณธ ์„ค์ • ๊ฐ’์œผ๋กœ health์™€ info ๊ฐ€ ์ง€์ •๋˜์–ด์žˆ๋Š”๋ฐ, ์šฐ๋ฆฌ๋Š” info ๊ธฐ๋Šฅ์ด ์•„๋‹Œ beans ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๋ ค ํ•˜๋‹ˆ ์œ„์™€ ๊ฐ™์ด ์ง์ ‘ ์ง€์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  Spring Boot Application์ด ๋™์ž‘ํ•˜๋Š” ์„œ๋ฒ„๋ฅผ ํ–ฅํ•ด์„œ http://server.com/actuator/health์— GET ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ˜„์žฌ ์ƒํƒœ์˜ ์ •๋ณด๊ฐ€ ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

Config Refresh

Actuator์˜ Config Refresh๋Š” ์„œ๋น„์Šค์˜ ๋ฐฐํฌ ๋ฐ ๋นŒ๋“œ ์—†์ด ํ™˜๊ฒฝ์„ค์ • ๋ณ€๊ฒฝ ๊ฐ’์„ ์—…๋ฐ์ดํŠธ ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์šฐ๋ฆฌ๋Š” ํ•ด๋‹น ๊ธฐ๋Šฅ์„ ์ด์šฉํ•ด์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์„ค์ • ๊ฐ’๋“ค์„ ๋นŒ๋“œ์™€ ๋ฐฐํฌ ์—†์ด ๋‹ค์‹œ ๋ฐ›์•„์˜ค๋ ค ํ•œ๋‹ค.

 

ํ•ด๋‹น Endpoint ๋ฅผ ํ™œ์„ฑํ™”์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ ์—ญ์‹œ application.yml ํŒŒ์ผ์˜ ์„ค์ •์„ ๋ณ€๊ฒฝํ•ด์ค˜์•ผ ํ•œ๋‹ค.

 

management:
  endpoints:
    web:
      exposure:
        include: refresh

 

๊ทธ๋ฆฌ๊ณ  ์ด๋ฒˆ์—๋Š” GET ์š”์ฒญ์ด ์•„๋‹Œ POST ์š”์ฒญ์„ ๋ณด๋‚ด์•ผ ํ•œ๋‹ค.

 

๋งŒ์•ฝ ์„ค์ • ์ •๋ณด๊ฐ€ ๋ณ€๊ฒฝ๋œ ์ด๋ ฅ์ด ์žˆ๋‹ค๋ฉด ์‘๋‹ต์œผ๋กœ ์–ด๋–ค ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜์—ˆ๋Š”์ง€๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

 

์ž์„ธํ•œ ๋‚ด์šฉ์€ ์•„๋ž˜์—์„œ ์ง์ ‘ ์‹ค์Šต์„ ํ†ตํ•ด์„œ ์•Œ์•„๋ณด์ž.

 

Spring Boot Actuator ๋ฅผ ์ด์šฉํ•ด์„œ ๋ณ€๊ฒฝ ์ •๋ณด ๊ฐฑ์‹ ํ•˜๊ธฐ

์ด์ œ ์‹ค์ œ๋กœ ์šฐ๋ฆฌ์˜ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ์ธ์Šคํ„ด์Šค์ธ User-Service ์— ์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ ์šฉ์‹œ์ผœ๋ณด๋ ค ํ•œ๋‹ค.

์šฐ์„  ํ•ด๋‹น ์‹ค์Šต์„ ์œ„ํ•ด์„œ๋Š” Spring Config ์„œ๋ฒ„์™€ User-service๊ฐ€ ๊ธฐ๋™๋˜์–ด ์žˆ์–ด์•ผ ํ•˜๋Š”๋ฐ, ๋งŒ์•ฝ Config ์„œ๋ฒ„์™€ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค๊ฐ€ ์„ค์ • ๋ณ€๊ฒฝ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋„๋ก ํ™˜๊ฒฝ์ด ๊ตฌ์ถ•์ด ๋˜์–ด์žˆ์ง€ ์•Š๋‹ค๋ฉด Spring Cloud Config์˜ name, profiles ๊ทธ๋ฆฌ๊ณ  Github ๋ฅผ ์—ฐ๋™ํ•ด์„œ ์„ค์ • ํŒŒ์ผ ๊ด€๋ฆฌํ•˜๊ธฐ ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์šฐ๋ฆฌ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณผ์ •์œผ๋กœ ์‹ค์Šต์„ ์ง„ํ–‰ํ•˜๋ ค ํ•œ๋‹ค.

 

์‹ค์Šต ๊ณผ์ •

 

  1. User-Service์— Actuator ์˜์กด์„ฑ ์ถ”๊ฐ€ํ•˜๊ธฐ
  2. refresh Endpoints ํ™œ์„ฑํ™”
  3. ์›๊ฒฉ ์ €์žฅ์†Œ์— ์žˆ๋Š” yml ์„ค์ • ์ •๋ณด ๋ณ€๊ฒฝํ•˜๊ธฐ
  4. refresh ํ•˜๊ธฐ

User-Service์— Actuator ์˜์กด์„ฑ ์ถ”๊ฐ€ํ•˜๊ธฐ

์šฐ๋ฆฌ๊ฐ€ ์ง€๋‚œ ์‹œ๊ฐ„ ๊ตฌ์„ฑํ•œ User-Service ์—์„œ Actuator๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•ด๋ณด์ž.

 

๋˜ํ•œ bootstrap ์„ ์ด์šฉํ•ด์„œ ์„ค์ • ์ •๋ณด๋ฅผ ๋กœ๋“œํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— bootstrap ์˜์กด์„ฑ๋„ ํ•จ๊ป˜ ํ•„์š”ํ•˜๋‹ค.

 

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'

 

๊ทธ๋ฆฌ๊ณ  ๋ณ€๊ฒฝ๋œ ์‚ฌํ•ญ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ User-Service ์˜ ์ฝ”๋“œ๋ฅผ ์กฐ๊ธˆ ์ˆ˜์ •ํ•  ๊ฒƒ์ด๋‹ค.

 

@SpringBootApplication
@RestController
public class UserServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(UserServiceApplication.class, args);
    }

    @GetMapping("/config/database")
    public String database(@Value("${spring.datasource.driver}") String driver,
                           @Value("${spring.datasource.url}") String url,
                           @Value("${spring.datasource.username}") String username,
                           @Value("${spring.datasource.password}") String password,
                           @Value("${jwt.token.key}") String tokenKey) {
        return "driver: " + driver + "\n"
                + "url: " + url + "\n"
                + "username: " + username + "\n"
                + "password: " + password + "\n\n"
                + "token key: " + tokenKey;
    }
}

 

๊ทธ๋ฆฌ๊ณ  ์ง€๋‚œ ์‹œ๊ฐ„ ๊ตฌ์„ฑํ–ˆ๋˜ Git ์ €์žฅ์†Œ์— ์žˆ๋Š” config ํŒŒ์ผ๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž‘์„ฑ๋˜์–ด์žˆ๋‹ค.

 

# application.yml
default:
  owner: config-service's git folder
  content: :) ์•ˆ๋…•ํ•˜์„ธ์š” ๊ฐ๊ฐ์˜ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉ๋  ๋ฐ์ดํ„ฐ์ž…๋‹ˆ๋‹ค. :) 2

# user-service.yml
jwt:
  token:
    key: "{cipher}8fe09399c96cdc1bee0cc3dafea404335a5bdd879e4cd85547fd1e7fbe774e11b3adc2c20634d16501be77987bbc210f"

# user-service-test.yml
spring:
  datasource:
    driver: com.mysql.jdbc.Driver
    url: http://db.com
    username: test23
    password: test2

refresh Endpoints ํ™œ์„ฑํ™”

์ด์ œ actuator ์˜ endpoints ๋ฅผ ์—ด๋Ÿฌ์ฃผ๋„๋ก ํ•˜์ž.

 

์ง€๋‚œ ์‹œ๊ฐ„ ํ™˜๊ฒฝ ์„ค์ •์„ ๋”ฐ๋ผ์™”๋‹ค๋ฉด ๋ฌธ์ œ๊ฐ€ ์—†๊ฒ ์ง€๋งŒ ๋‹ค์‹œ ํ•œ ๋ฒˆ ์™ธ๋ถ€ ์„ค์ • ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ Config ์„œ๋ฒ„์˜ ์ฃผ์†Œ๋„ ์ ์–ด๋ณด์ž.

 

spring:
  cloud:
    config:
      uri: http://localhost:8888
      name: user-service
      profile: test

management:
  endpoints:
    web:
      exposure:
        include: refresh

 

์œ„์˜ ๋‚ด์šฉ์€ bootstrap.yml ์— ์ ์–ด์ฃผ๋„๋ก ํ•˜์ž.

 

๊ทธ๋ฆฌ๊ณ  User ์„œ๋น„์Šค๋ฅผ ์‹คํ–‰์‹œ์ผœ๋ณด์ž.

 

ํ•ด๋‹น ์„œ๋น„์Šค๋Š” ๊ณ„์†ํ•ด์„œ ์ผœ๋‘์ž. ์šฐ๋ฆฌ๋Š” ์„ค์ • ์ •๋ณด๋ฅผ ๋นŒ๋“œ๋‚˜ ์žฌ๊ธฐ๋™ ์—†์ด ๋ฐ˜์˜ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๊ธฐ ๋•Œ๋ฌธ์—!

์›๊ฒฉ ์ €์žฅ์†Œ์— ์žˆ๋Š” yml ์„ค์ • ์ •๋ณด ๋ณ€๊ฒฝํ•˜๊ธฐ

ํ˜„์žฌ Config ์„œ๋ฒ„์™€ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค๋“ค์€ ์•„๋ž˜์™€ ๊ฐ™์€ ๊ตฌ์กฐ๋กœ ๋˜์–ด์žˆ๋‹ค.

 

 

์ด์ œ Config ์„œ๋ฒ„๊ฐ€ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ๋Š” git ์ €์žฅ์†Œ์— ์žˆ๋Š” yml ํŒŒ์ผ๋“ค์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•ด๋ณผ ๊ฒƒ์ด๋‹ค.

 

# application.yml
default:
  owner: config-service's git folder
  content: :) ์•ˆ๋…•ํ•˜์„ธ์š” ๊ฐ๊ฐ์˜ ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค์—์„œ ์‚ฌ์šฉ๋  ๋ฐ์ดํ„ฐ์ž…๋‹ˆ๋‹ค. :) 2

# user-service.yml
jwt:
  token:
    key: "{cipher}8fe09399c96cdc1bee0cc3dafea404335a5bdd879e4cd85547fd1e7fbe774e11b3adc2c20634d16501be77987bbc210f"

# user-service-test.yml
spring:
  datasource:
    driver: com.h2.Driver
    url: http://new-db-url.com
    username: admin
    password: admin

์œ„์™€ ๊ฐ™์ด ์ˆ˜์ •์„ ํ•˜๊ณ  ์›๊ฒฉ ์ €์žฅ์†Œ์— push ๋ฅผ ๋ณด๋‚ด์ž.

 

refresh ํ•˜๊ธฐ

 

์œ„์—์„œ ์šฐ๋ฆฌ๋Š” config ํŒŒ์ผ์„ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์‹ค์ œ ์„ค์ • ์ •๋ณด๋Š” ๋ณ€๊ฒฝ์ด ๋˜์—ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ ์šฐ๋ฆฌ์˜ ์„œ๋ฒ„์—๋Š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์ €์žฅ๋˜์ง€ ์•Š์•˜๋‹ค.

 

์ด ๋•Œ, Configuration ์ •๋ณด๋งŒ refresh ํ•˜๋Š” Actuator์˜ Refresh ํ˜ธ์ถœ์„ POST๋กœ ๋ณด๋‚ด๋ณด์ž.

๊ทธ๋Ÿผ ์–ด๋–ค ์ •๋ณด๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ๋Š”์ง€ ์‘๋‹ต์œผ๋กœ ์œ„์™€ ๊ฐ™์ด ๋ฐ›๊ฒŒ ๋˜๊ณ  ์„œ๋ฒ„์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ƒˆ๋กœ์šด ์ •๋ณด๊ฐ€ ๋ฐ˜์˜๋˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

๋Œ“๊ธ€