feat: 重构项目脚本结构和文档
docs: 添加API和部署文档 refactor: 重新组织脚本目录结构 fix: 修复Nomad配置中的region设置 chore: 移除过期节点相关配置 test: 更新MCP服务器测试脚本 build: 更新Makefile以适配新脚本路径
This commit is contained in:
@@ -3,7 +3,6 @@ job "traefik" {
|
||||
type = "service"
|
||||
|
||||
update {
|
||||
strategy = "canary"
|
||||
max_parallel = 1
|
||||
min_healthy_time = "10s"
|
||||
healthy_deadline = "3m"
|
||||
@@ -11,7 +10,14 @@ job "traefik" {
|
||||
}
|
||||
|
||||
group "traefik" {
|
||||
count = 3
|
||||
count = 1 # 先在warden节点部署一个实例
|
||||
|
||||
# 约束只在warden节点运行
|
||||
constraint {
|
||||
attribute = "${node.unique.name}"
|
||||
operator = "="
|
||||
value = "bj-warden"
|
||||
}
|
||||
|
||||
restart {
|
||||
attempts = 3
|
||||
@@ -33,21 +39,66 @@ job "traefik" {
|
||||
}
|
||||
|
||||
task "traefik" {
|
||||
driver = "podman"
|
||||
driver = "exec"
|
||||
|
||||
# 下载Traefik v3二进制文件
|
||||
artifact {
|
||||
source = "https://github.com/traefik/traefik/releases/download/v3.1.5/traefik_v3.1.5_linux_amd64.tar.gz"
|
||||
destination = "local/"
|
||||
mode = "file"
|
||||
options {
|
||||
archive = "true"
|
||||
}
|
||||
}
|
||||
|
||||
# 动态配置文件模板
|
||||
template {
|
||||
data = <<EOF
|
||||
# Traefik动态配置 - 从Consul获取服务
|
||||
http:
|
||||
routers:
|
||||
consul-master:
|
||||
rule: "Host(`consul-master.service.consul`)"
|
||||
service: consul-master
|
||||
entryPoints: ["http"]
|
||||
|
||||
services:
|
||||
consul-master:
|
||||
loadBalancer:
|
||||
servers:
|
||||
{{ range nomadService "consul" }}
|
||||
{{ if contains .Tags "http" }}
|
||||
- url: "http://{{ .Address }}:{{ .Port }}"
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
# Consul Catalog配置
|
||||
providers:
|
||||
consulCatalog:
|
||||
exposedByDefault: false
|
||||
prefix: "traefik"
|
||||
refreshInterval: 15s
|
||||
endpoint:
|
||||
address: "http://{{ with nomadService "consul" }}{{ range . }}{{ if contains .Tags "http" }}{{ .Address }}:{{ .Port }}{{ end }}{{ end }}{{ end }}"
|
||||
connectAware: true
|
||||
connectByDefault: false
|
||||
EOF
|
||||
destination = "local/dynamic.yml"
|
||||
change_mode = "restart"
|
||||
}
|
||||
|
||||
config {
|
||||
image = "traefik:latest"
|
||||
ports = ["http", "https", "api"]
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock:ro", # 如果需要与Docker集成
|
||||
"/root/mgmt/configs/traefik.yml:/etc/traefik/traefik.yml:ro",
|
||||
"/root/mgmt/configs/dynamic:/etc/traefik/dynamic:ro"
|
||||
command = "local/traefik"
|
||||
args = [
|
||||
"--configfile=/root/mgmt/infrastructure/routes/traefik.yml",
|
||||
"--providers.file.filename=local/dynamic.yml",
|
||||
"--providers.file.watch=true"
|
||||
]
|
||||
}
|
||||
|
||||
env {
|
||||
NOMAD_ADDR = "http://${attr.unique.network.ip-address}:4646"
|
||||
CONSUL_HTTP_ADDR = "http://${attr.unique.network.ip-address}:8500"
|
||||
# Consul地址将通过template动态获取
|
||||
}
|
||||
|
||||
resources {
|
||||
@@ -56,14 +107,15 @@ job "traefik" {
|
||||
}
|
||||
|
||||
service {
|
||||
name = "traefik"
|
||||
name = "traefik-warden"
|
||||
port = "http"
|
||||
tags = [
|
||||
"traefik.enable=true",
|
||||
"traefik.http.routers.api.rule=Host(`traefik.service.consul`)",
|
||||
"traefik.http.routers.api.service=api@internal",
|
||||
"traefik.http.routers.api.entrypoints=api",
|
||||
"traefik.http.services.api.loadbalancer.server.port=8080"
|
||||
"traefik.http.routers.traefik-warden.rule=Host(`traefik.warden.consul`)",
|
||||
"traefik.http.routers.traefik-warden.service=api@internal",
|
||||
"traefik.http.routers.traefik-warden.entrypoints=api",
|
||||
"traefik.http.services.traefik-warden.loadbalancer.server.port=8080",
|
||||
"warden"
|
||||
]
|
||||
|
||||
check {
|
||||
|
||||
Reference in New Issue
Block a user