feat: 重构项目目录结构并添加多个功能
- 新增脚本和配置文件用于管理Nomad节点和NFS存储 - 添加多个Ansible playbook用于配置和调试Nomad集群 - 新增Nomad job文件用于测试Podman和NFS功能 - 重构playbooks目录结构,按功能分类 - 更新Nomad客户端和服务端配置模板 - 添加SSH密钥分发和配置脚本 - 新增多个调试和修复问题的playbook
This commit is contained in:
65
jobs/hybrid-nfs-app.nomad
Normal file
65
jobs/hybrid-nfs-app.nomad
Normal file
@@ -0,0 +1,65 @@
|
||||
job "hybrid-nfs-app" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
# 使用约束条件区分存储类型
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
operator = "regexp"
|
||||
value = "semaphore"
|
||||
}
|
||||
|
||||
group "app" {
|
||||
count = 1
|
||||
|
||||
network {
|
||||
port "http" {
|
||||
static = 8080
|
||||
}
|
||||
}
|
||||
|
||||
# 对于本机(semaphore)使用host volume
|
||||
volume "local-storage" {
|
||||
type = "host"
|
||||
read_only = false
|
||||
source = "local-fnsync"
|
||||
}
|
||||
|
||||
task "web-app" {
|
||||
driver = "exec"
|
||||
|
||||
config {
|
||||
command = "python3"
|
||||
args = ["-m", "http.server", "8080", "--directory", "local/fnsync"]
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOH
|
||||
<h1>Hybrid NFS App - Running on {{ env "attr.unique.hostname" }}</h1>
|
||||
<p>Storage Type: {{ with eq (env "attr.unique.hostname") "semaphore" }}PVE Mount{{ else }}NFS{{ end }}</p>
|
||||
<p>Timestamp: {{ now | date "2006-01-02 15:04:05" }}</p>
|
||||
EOH
|
||||
destination = "local/fnsync/index.html"
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 128
|
||||
}
|
||||
|
||||
service {
|
||||
name = "hybrid-nfs-app"
|
||||
port = "http"
|
||||
|
||||
tags = ["hybrid", "nfs", "web"]
|
||||
|
||||
check {
|
||||
type = "http"
|
||||
path = "/"
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
jobs/nfs-app-example.nomad
Normal file
51
jobs/nfs-app-example.nomad
Normal file
@@ -0,0 +1,51 @@
|
||||
job "nfs-app-example" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
group "app" {
|
||||
count = 1
|
||||
|
||||
# 使用NFS存储卷
|
||||
volume "nfs-storage" {
|
||||
type = "host"
|
||||
read_only = false
|
||||
source = "nfs-fnsync"
|
||||
}
|
||||
|
||||
task "web-app" {
|
||||
driver = "docker"
|
||||
|
||||
config {
|
||||
image = "nginx:alpine"
|
||||
ports = ["http"]
|
||||
|
||||
# 挂载NFS卷到容器
|
||||
mount {
|
||||
type = "volume"
|
||||
target = "/usr/share/nginx/html"
|
||||
source = "nfs-storage"
|
||||
readonly = false
|
||||
}
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 128
|
||||
}
|
||||
|
||||
service {
|
||||
name = "nfs-web-app"
|
||||
port = "http"
|
||||
|
||||
tags = ["nfs", "web"]
|
||||
|
||||
check {
|
||||
type = "http"
|
||||
path = "/"
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
jobs/nfs-storage-test.nomad
Normal file
34
jobs/nfs-storage-test.nomad
Normal file
@@ -0,0 +1,34 @@
|
||||
job "nfs-storage-test" {
|
||||
datacenters = ["dc1"]
|
||||
type = "batch"
|
||||
|
||||
group "test" {
|
||||
count = 1
|
||||
|
||||
volume "nfs-storage" {
|
||||
type = "csi"
|
||||
read_only = false
|
||||
source = "nfs-fnsync"
|
||||
}
|
||||
|
||||
task "storage-test" {
|
||||
driver = "exec"
|
||||
|
||||
volume_mount {
|
||||
volume = "nfs-storage"
|
||||
destination = "/mnt/nfs"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
config {
|
||||
command = "/bin/sh"
|
||||
args = ["-c", "echo 'NFS Storage Test - $(hostname) - $(date)' > /mnt/nfs/test-$(hostname).txt && ls -la /mnt/nfs/"]
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 50
|
||||
memory = 64
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
jobs/nomad-nfs-multi-type.nomad
Normal file
84
jobs/nomad-nfs-multi-type.nomad
Normal file
@@ -0,0 +1,84 @@
|
||||
job "nfs-multi-type-example" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
# 为本地LXC容器配置的任务组
|
||||
group "lxc-apps" {
|
||||
count = 2
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
operator = "regexp"
|
||||
value = "(influxdb|hcp)"
|
||||
}
|
||||
|
||||
volume "lxc-nfs" {
|
||||
type = "host"
|
||||
source = "nfs-shared"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
task "lxc-app" {
|
||||
driver = "podman"
|
||||
|
||||
config {
|
||||
image = "alpine:latest"
|
||||
args = ["tail", "-f", "/dev/null"]
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "lxc-nfs"
|
||||
destination = "/shared/lxc"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 64
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 为海外PVE容器配置的任务组
|
||||
group "pve-apps" {
|
||||
count = 3
|
||||
|
||||
constraint {
|
||||
attribute = "${attr.unique.hostname}"
|
||||
operator = "regexp"
|
||||
value = "(ash1d|ash2e|ash3c|ch2|ch3)"
|
||||
}
|
||||
|
||||
volume "pve-nfs" {
|
||||
type = "host"
|
||||
source = "nfs-shared"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
task "pve-app" {
|
||||
driver = "podman"
|
||||
|
||||
config {
|
||||
image = "alpine:latest"
|
||||
args = ["tail", "-f", "/dev/null"]
|
||||
|
||||
# 为海外节点添加网络优化参数
|
||||
network_mode = "host"
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "pve-nfs"
|
||||
destination = "/shared/pve"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 64
|
||||
network {
|
||||
mbits = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
jobs/podman/nomad-nfs-volume.nomad
Normal file
34
jobs/podman/nomad-nfs-volume.nomad
Normal file
@@ -0,0 +1,34 @@
|
||||
job "nfs-volume-example" {
|
||||
datacenters = ["dc1"]
|
||||
type = "service"
|
||||
|
||||
group "nfs-app" {
|
||||
count = 1
|
||||
|
||||
volume "nfs-shared" {
|
||||
type = "host"
|
||||
source = "nfs-shared"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
task "app" {
|
||||
driver = "podman"
|
||||
|
||||
config {
|
||||
image = "alpine:latest"
|
||||
args = ["tail", "-f", "/dev/null"]
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "nfs-shared"
|
||||
destination = "/shared"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 100
|
||||
memory = 64
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user