今天介紹如何在Nomad job裡掛上host volume.
要在Nomad job裡設定像docker可以mount volume,要在Nomad client裡規劃host_volume
.
/alloc
這個是Nomad預設的,它在host實際的位置會在f5ea985a
-fccd-3a8d-9e3b-770a23806fac/allocnomad job status erp
來查看host的對應位置。$ nomad job status erp
...
...
Allocations
ID Node ID Task Group Version Desired Status Created Modified
f5ea985a a7db9bf6 webfront 0 run running 16m22s ago 15m51s ago
constraint
讓job固定在某幾台Nomad client上。client {
enabled = true
servers = ["10.168.1.135:4647"]
server_join {
retry_join = ["10.168.1.135:4647"]
retry_max = 3
retry_interval = "15s"
}
host_volume "ithome01" {
path = "/home/ec2-user/client_volumes/v01"
read_only = false
}
host_volume "ithome02" {
path = "/home/ec2-user/client_volumes/v02"
read_only = false
}
...
...
}
...
...
可以從Web UI看到client volume數是2,新增成功。
job "erp" {
datacenters = ["Nomad-WHQ-DEV"]
group "webfront" {
count = 1
volume "task_ithome" {
type = "host"
read_only = false
source = "ithome01"
}
....
task "nginx" {
...
volume_mount {
volume = "task_ithome"
destination = "/ithome"
read_only = false
}
...
說明: