democratic_csi/controller.nomad.hcl

91 lines
2.0 KiB
HCL
Raw Permalink Normal View History

2023-12-21 22:16:14 +01:00
job "[[ .instance ]]-controller" {
2023-10-08 16:24:28 +02:00
[[ $c := merge .democratic_csi . -]]
2024-01-21 23:10:41 +01:00
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 ]]-controller" {
2023-08-21 20:16:35 +02:00
[[ $c := merge $c.controller $c ]]
2024-01-21 23:10:41 +01:00
count = [[ $c.count ]]
2023-08-21 20:16:35 +02:00
[[ template "common/constraints" $c ]]
2024-03-27 11:13:18 +01:00
service {
name = "[[ $.instance ]]-[[ $proto ]]-controller[[ $.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 22:52:52 +02:00
task "[[ $proto ]]-controller" {
2023-08-21 20:16:35 +02:00
2024-01-21 23:10:41 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-08-21 20:16:35 +02:00
env {
2024-01-22 21:55:54 +01:00
NODE_EXTRA_CA_CERTS = "/local/ca.crt"
2023-08-21 20:16:35 +02:00
}
2024-01-22 21:55:54 +01:00
[[ template "common/file_env" $c ]]
2023-08-21 20:16:35 +02:00
vault {
2024-01-31 13:42:29 +01:00
policies = ["[[ $.instance ]][[ $.consul.suffix ]]"]
env = false
disable_file = true
2023-08-21 20:16:35 +02:00
}
config {
2024-01-21 23:10:41 +01:00
image = "[[ $.democratic_csi.image ]]"
2023-08-21 20:16:35 +02:00
args = [
"--csi-version=1.5.0",
"--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=controller",
"--server-socket=/csi/csi.sock"
]
network_mode = "host"
privileged = true
userns_mode = "host"
}
template {
data =<<_EOF
2024-01-21 23:10:41 +01:00
[[ tmpl.Exec (printf "democratic_csi/%s/controller.yml.tpl" $proto) $c ]]
2023-08-21 20:16:35 +02:00
_EOF
destination = "secrets/config.yml"
}
# Load vault root CA into the trust store
template {
data = <<-EOF
2024-01-31 13:38:19 +01:00
{{ with secret "[[ $.vault.pki.issuer ]]/cert/ca" }}{{ .Data.certificate }}{{ end }}
2023-08-21 20:16:35 +02:00
EOF
destination = "local/ca.crt"
}
csi_plugin {
id = "[[ $.democratic_csi.plugin_id ]].[[ $proto ]]"
type = "controller"
mount_dir = "/csi"
health_timeout = "2m"
2023-08-21 20:16:35 +02:00
}
2024-01-21 23:10:41 +01:00
[[ template "common/resources" $c ]]
2023-08-21 20:16:35 +02:00
}
}
[[- end ]]
}
# vim: syntax=hcl