在 Nomad 中使用 CSI 驱动
注意
此特性需使用 0.13.2 及以上版本的 JuiceFS CSI 驱动
安装 JuiceFS CSI 驱动
前置条件
-
Nomad 版本在 v0.12.0 及以上。
-
开启 privileged Docker jobs。如果您的 Nomad 客户端配置尚未指定 Docker 插件配置,将以下最小配置文件添加到您的 Nomad 客户端配置并重 新启动 Nomad:
plugin "docker" {
config {
allow_privileged = true
}
}
安装 CSI Controller
将以下配置文件保存为文件 csi-controller.nomad
:
csi-controller.nomad
job "jfs-controller" {
datacenters = ["dc1"]
type = "system"
group "controller" {
task "plugin" {
driver = "docker"
config {
image = "juicedata/juicefs-csi-driver:v0.14.1"
args = [
"--endpoint=unix://csi/csi.sock",
"--logtostderr",
"--nodeid=test",
"--v=5",
"--by-process=true"
]
privileged = true
}
csi_plugin {
id = "juicefs0"
type = "controller"
mount_dir = "/csi"
}
resources {
cpu = 100
memory = 512
}
env {
POD_NAME = "csi-controller"
}
}
}
}
启动 CSI Controller job:
$ nomad job run csi-controller.nomad
==> 2022-03-14T17:00:20+08:00: Monitoring evaluation "2287baf7"
2022-03-14T17:00:20+08:00: Evaluation triggered by job "jfs-controller"
2022-03-14T17:00:20+08:00: Allocation "00806191" created: node "0673a790", group "controller"
==> 2022-03-14T17:00:21+08:00: Monitoring evaluation "2287baf7"
2022-03-14T17:00:21+08:00: Allocation "00806191" status changed: "pending" -> "running" (Tasks are running)
2022-03-14T17:00:21+08:00: Evaluation status changed: "pending" -> "complete"
==> 2022-03-14T17:00:21+08:00: Evaluation "2287baf7" finished with status "complete"
运行命令 nomad job status jfs-controller
可检查 CSI Controller 是否正常运行:
$ nomad job status jfs-controller
ID = jfs-controller
Name = jfs-controller
Submit Date = 2022-03-14T17:00:20+08:00
Type = system
Priority = 50
Datacenters = dc1
Namespace = default
Status = running
Periodic = false
Parameterized = false
Summary
Task Group Queued Starting Running Failed Complete Lost
controller 0 0 1 0 0 0
Allocations
ID Node ID Task Group Version Desired Status Created Modified
00806191 0673a790 controller 0 run running 31m47s ago 31m42s ago
在上述输出中,Allocation
状态为 running
即代表 CSI Controller 启动成功。
安装 CSI Node
将以下配置文件保存为文件 csi-node.nomad
:
csi-node.nomad
job "jfs-node" {
datacenters = ["dc1"]
type = "system"
group "nodes" {
task "juicefs-plugin" {
driver = "docker"
config {
image = "juicedata/juicefs-csi-driver:v0.14.1"
args = [
"--endpoint=unix://csi/csi.sock",
"--logtostderr",
"--v=5",
"--nodeid=test",
"--by-process=true",
]
privileged = true
}
csi_plugin {
id = "juicefs0"
type = "node"
mount_dir = "/csi"
}
resources {
cpu = 1000
memory = 1024
}
env {
POD_NAME = "csi-node"
}
}
}
}
启动 CSI Node job:
$ nomad job run csi-node.nomad
==> 2022-03-14T17:01:15+08:00: Monitoring evaluation "31d7ed49"
2022-03-14T17:01:15+08:00: Evaluation triggered by job "jfs-node"
2022-03-14T17:01:15+08:00: Allocation "047a1386" created: node "0673a790", group "nodes"
2022-03-14T17:01:15+08:00: Evaluation status changed: "pending" -> "complete"
==> 2022-03-14T17:01:15+08:00: Evaluation "31d7ed49" finished with status "complete"
运行命令 nomad job status jfs-node
可检查 CSI Node 是否正常运行:
$ nomad job status jfs-node
ID = jfs-node
Name = jfs-node
Submit Date = 2022-03-14T17:01:15+08:00
Type = system
Priority = 50
Datacenters = dc1
Namespace = default
Status = running
Periodic = false
Parameterized = false
Summary
Task Group Queued Starting Running Failed Complete Lost
nodes 0 0 1 0 0 0
Allocations
ID Node ID Task Group Version Desired Status Created Modified
047a1386 0673a790 nodes 0 run running 28m41s ago 28m35s ago
在上述输出中,Allocation
状态为 running
即代表 CSI Node 启动成功。