democratic_csi/node.nomad.hcl

96 lines
2.1 KiB
HCL
Raw Normal View History

2023-12-21 22:16:14 +01:00
job "[[ .instance ]]-node" {
2024-01-21 23:10:41 +01:00
[[ $c := merge .democratic_csi.node .democratic_csi . -]]
2023-08-21 20:16:35 +02:00
type = "system"
2023-12-15 15:08:02 +01:00
[[- template "common/job_start" $c ]]
2023-08-21 20:16:35 +02:00
2024-01-21 23:10:41 +01:00
[[- range $proto := coll.Slice "iscsi" "nfs" ]]
2023-08-21 22:52:52 +02:00
group "[[ $proto ]]-node" {
2023-08-21 20:16:35 +02:00
2024-03-27 11:13:18 +01:00
[[ template "common/constraints" $c ]]
service {
name = "[[ $.instance ]]-[[ $proto ]]-node[[ $.consul.suffix ]]"
[[ template "common/service_meta" $c ]]
}
2023-12-01 09:57:47 +01:00
restart {
interval = "5m"
attempts = 30
delay = "10s"
mode = "delay"
}
2023-08-21 20:16:35 +02:00
[[- if eq $proto "iscsi" ]]
2023-12-15 15:08:02 +01:00
[[- template "common/volumes" $.democratic_csi.node.volumes ]]
2023-08-21 20:16:35 +02:00
[[- end ]]
task "[[ $proto ]]-node" {
2024-01-21 23:10:41 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-08-21 20:16:35 +02:00
config {
2024-01-21 23:10:41 +01:00
image = "[[ $c.image ]]"
2023-08-21 20:16:35 +02:00
args = [
"--csi-version=1.5.0",
# must match the csi_plugin.id attribute below
"--csi-name=[[ $.democratic_csi.plugin_id ]].[[ $proto ]]",
2023-08-21 20:16:35 +02:00
"--driver-config-file=/secrets/config.yml",
"--log-level=info",
"--csi-mode=node",
"--server-socket=/csi/csi.sock",
]
# node plugins must run as privileged jobs because they
# mount disks to the host
userns_mode = "host"
privileged = true
ipc_mode = "host"
network_mode = "host"
}
2024-01-21 23:10:41 +01:00
env {
CSI_NODE_ID = "${attr.unique.hostname}"
}
[[ template "common/file_env" $c ]]
2023-08-21 20:16:35 +02:00
template {
data =<<_EOF
2024-01-21 23:10:41 +01:00
[[ tmpl.Exec (printf "democratic_csi/%s/node.yml.tpl" $proto) $c ]]
2023-08-21 20:16:35 +02:00
_EOF
destination = "secrets/config.yml"
}
csi_plugin {
# must match --csi-name arg
id = "[[ $.democratic_csi.plugin_id ]].[[ $proto ]]"
2023-08-21 20:16:35 +02:00
type = "node"
mount_dir = "/csi"
}
[[- if eq $proto "iscsi" ]]
volume_mount {
volume = "host_root"
destination = "/host"
propagation_mode = "bidirectional"
}
volume_mount {
volume = "host_run_udev"
destination = "/run/udev"
}
[[- end ]]
2024-01-21 23:10:41 +01:00
[[ template "common/resources" $c ]]
2023-08-21 20:16:35 +02:00
}
}
2023-08-21 22:52:52 +02:00
[[- end ]]
2023-08-21 20:16:35 +02:00
}
# vim: syntax=hcl