초기엔 각각의 Nomad job 파일을 별도로 작성해 배포
서비스가 늘어날수록 관리가 복잡해지고, Job 하나 바꿀 때마다 다른 서비스와의 연결 상태가 깨지거나 누락되는 문제가 발생'
아래와 같이 하나의 파일로 비슷한 유형의 서비스 일괄 배포 가능하도록 수정
- api-service : api task들을 group 단위로 모아 실행
- database-service : service들을 group 단위로 모아 실행
- persist-infra : system-infra와 DB등 고가용성 서비스들을 모아 실행
- 이외에도 device관련 계층 등의 서비스를 모아 실행
job "persist-infra" {
datacenters = ["dc1"]
group "persist-infra-group" {
count = 1
network {
port "influxdb" {
static = 8086
}
port "grafana" {
static = 3000
}
port "redis" {
static = 6379
}
port "redis-commander" {
static = 8081
}
port "mongodb" {
static = 27017
}
}
task "telegraf" {
driver = "raw_exec"
config {
command = "/usr/bin/telegraf"
args = ["--config", "/etc/telegraf/telegraf.conf"]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "influxdb" {
driver = "raw_exec"
config {
command = "/usr/bin/influxd"
args = ["--config", "/etc/influxdb/influxdb.conf"]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "grafana" {
driver = "raw_exec"
config {
command = "/usr/sbin/grafana-server"
args = [
"--homepath=/usr/share/grafana",
"--config=/etc/grafana/grafana.ini",
"web"
]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "redis" {
driver = "raw_exec"
config {
command = "/usr/local/bin/redis-server"
args = [
"/usr/local/src/redis-7.4.2/redis.conf",
"--bind", "0.0.0.0", "::",
"--protected-mode", "no",
"--port", "6379"
]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "redis-commander" {
driver = "raw_exec"
config {
command = "/usr/bin/redis-commander"
args = [
"--redis-host=127.0.0.1",
"--bind", "0.0.0.0", "::",
"--redis-port=6379",
"--port=8081"
]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "fluentd" {
driver = "raw_exec"
config {
command = "/usr/local/bin/fluentd"
args = [
"-c",
"/usr/local/share/gems/gems/fluentd-1.18.0/fluent.conf"
]
}
logs {
max_files = 5
max_file_size = 10
}
}
task "mongodb" {
driver = "raw_exec"
config {
command = "/usr/bin/mongod"
args = [
"--config", "/etc/mongod.conf",
"--dbpath", "/system_storage/mongo",
"--bind_ip", "0.0.0.0"
]
}
logs {
max_files = 5
max_file_size = 10
}
}
restart {
attempts = 2
interval = "30s"
delay = "15s"
mode = "delay"
}
}
}
위와 같은 구조를 통해 하나의 파일로 전체 서비스를 일괄 배포가 가능해졌고,
서비스 변경 시에도 일부 task만 수정할 수 있고, 장애 발생 시 nomad가 자동으로 재시작/복구할 수 있게 됨
'Infrastructure > Nomad' 카테고리의 다른 글
[Nomad] HashiCorp Nomad 오케스트레이션 이슈 정리 (0) | 2024.12.16 |
---|---|
[Nomad] Nomad에서 raw_exec 드라이버 사용 (0) | 2024.08.19 |
[Nomad] Nomad 오케스트레이션 설정 방법 (0) | 2024.08.08 |