democratic_csi/node.nomad.hcl

90 lines
2.0 KiB
HCL

job "democratic-csi-node" {
datacenters = [[ .nomad.datacenters | toJSON ]]
type = "system"
# Run on all nodes, not matter which pool they belong
node_pool = "all"
[[ range $proto := slice "iscsi" "nfs" ]]
group "[[ $proto ]]" {
[[- if eq $proto "iscsi" ]]
volume "host_root" {
type = "host"
read_only = false
source = "host_root"
}
volume "host_run_udev" {
type = "host"
read_only = true
source = "host_run_udev"
}
[[- end ]]
task "[[ $proto ]]-node" {
driver = [[ democfratic_csi.node.driver | toJSON ]]
env {
CSI_NODE_ID = "${attr.unique.hostname}"
[[ template "common/env.tpl" . ]]
}
config {
image = [[ .democratic_csi.image | toJSON ]]
args = [
"--csi-version=1.5.0",
# must match the csi_plugin.id attribute below
"--csi-name=org.democratic-csi.[[ $proto ]]",
"--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"
}
template {
data =<<_EOF
[[ tmpl.Exec (printf "democratic_csi/%s/node.yml.tpl" $proto) . ]]
_EOF
destination = "secrets/config.yml"
}
csi_plugin {
# must match --csi-name arg
id = "org.democratic-csi.iscsi"
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 ]]
[[ template "common/resources.tpl" .democratic_csi.node.resources ]]
}
[[- end ]]
}
}
# vim: syntax=hcl