And Brain said,
Config Server, MSA의 중앙정보국 본문
오늘은 Spring Cloud Config Server에 대해 알아보자.
Config Server는 외부 환경 설정을 중앙 집중적으로 관리할 수 있도록 도와주는 역할을 한다.
예를 들어, 여러 대의 서버가 존재하는데 각각 서버별로 프로파일과 환경마다 설정이 다르다면 이를 중앙에서 관리해주지 않으면 설정 변경 시 모든 서버의 설정을 일일이 변경해주어야 하는 문제가 발생한다.
이런 이유로 환경 설정을 중앙에서 관리하고 필요한 서버에서 설정 정보를 가져와 사용하는 방식을 취하는것이 MSA의 Config Server이다.
https://theworldaswillandidea.tistory.com/112
Kotlin, The Evolution of Java (+ MSA with Spring boot)
오늘은 현재 안드로이드의 공식 언어이자 태생부터 진화된 자바를 표방한 언어, Kotlin에 대해 알아보고 Kotlin으로 구축하는 간단한 Spring boot 예제까지 배워보도록 하자. 최신 언어가 기존의 언어
theworldaswillandidea.tistory.com
지난 시간에 이어, MSA Config Server를 Kotlin으로 구축해보자.
똑같이 Spring initializr를 사용해서 만들어주도록 하고, build.gradle.kts 파일에 의존성을 주입한다.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.7.0"
id("io.spring.dependency-management") version "1.0.15.RELEASE"
kotlin("jvm") version "1.6.21"
kotlin("plugin.spring") version "1.6.21"
}
group = "com.spring.cloud"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
val springCloudVersion = "2021.0.4"
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springframework.cloud:spring-cloud-config-server")
implementation("org.springframework.cloud:spring-cloud-config-monitor") // webhook
//implementation("org.springframework.cloud:spring-cloud-starter-vault-config") // vault
implementation("org.springframework.boot:spring-boot-starter-actuator") // bus
implementation("org.springframework.cloud:spring-cloud-starter-bus-amqp") // bus
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
dependencyManagement {
imports {
mavenBom ("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
앞서, Vault를 사용하려 했으나 수많은 오류가 나와서 연동하는 것은 이후에 다시 시간이 날때 천천히 시도해보도록 하겠다...
application.yml 파일
server:
port: 8888
spring:
application:
name: config-service
cloud:
config:
server:
git:
uri: https://github.com/theman1697/config-file.git
username: '당신의 깃허브아이디'
password: 'github access token (암호화해서 사용하기 바람)'
search-paths: config-file # repository 폴더 경로
default-label: master # main branch
ignore-local-ssh-settings: true
skip-ssl-validation: true
bus:
enabled: true # webhook 활성화: /monitor 엔드포인트 호출 가능해진다
rabbitmq:
host: rabbitmqIp
port: 5672
username: guest
password: guest
# config server actuator
management:
endpoints:
web:
exposure:
include: busrefresh
RabbitMQ는 메시지 브로커인데 Spring Cloud bus를 이용해 애플리케이션들 간의 정보 전파를 위해 사용할 때, 메시지 브로커가 필요하다.
자세한 내용은 아래 참조
https://theworldaswillandidea.tistory.com/122
Spring Cloud Bus, MSA의 승강장
오늘은 Spring Cloud의 Bus에 대해 알아보도록 하자. MSA는 다들 잘 알다시피 여러 개의 마이크로서비스가 각각 독립적으로 동작하고 서로 통신하여 기능을 제공하는데 이때, 마이크로서비스들 간에
theworldaswillandidea.tistory.com
https://theworldaswillandidea.tistory.com/121
RabbitMQ, 비동기 메시지 큐를 위한 신문사
오늘은 MSA의 서비스 간 비동기 통신을 위한 미들웨어인 RabbitMQ에 대해 알아보고 실습까지 진행해보자. MSA에서는 각각의 서비스들의 결합도를 낮추고 유연성을 높이기 위해 RabbitMQ, Kafka, Redis같은
theworldaswillandidea.tistory.com
# ConfigApplication.kt
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.config.server.EnableConfigServer
@EnableConfigServer
@SpringBootApplication
class ConfigApplication
fun main(args: Array<String>) {
runApplication<ConfigApplication>(*args)
}
이후 ConfigServer를 활성화시켜준 뒤 구동하면 끝.
http://localhost:8888/actuator/health
잘 구동되었는지 확인해보자.
Thanks for watching, Have a nice day.
'IT > Java & Kotlin & Spring boot' 카테고리의 다른 글
Java, 객체지향의 화신 (0) | 2023.04.12 |
---|---|
QueryDSL, JPA ORM의 최종장 (0) | 2023.03.28 |
Spring Cloud Bus, MSA의 승강장 (0) | 2023.03.11 |
Spring boot Profile, 천의 얼굴을 가진 프로젝트 (0) | 2023.03.07 |
Kotlin, The Evolution of Java (+ MSA with Spring boot) (0) | 2023.02.19 |