egress-gateway/egress-gateway.nomad.hcl

70 lines
1.4 KiB
HCL
Raw Normal View History

2023-10-08 16:31:31 +02:00
[[ $c := merge .egress_gw . -]]
2023-08-22 15:24:35 +02:00
2023-12-21 22:24:32 +01:00
job [[ .instance | toJSON ]] {
2023-10-08 16:31:31 +02:00
2023-12-21 22:24:32 +01:00
[[ template "common/job_start" $c ]]
2023-08-22 15:24:35 +02:00
group "egress-gateway" {
network {
mode = "bridge"
}
# Terminating gateway definition
service {
2023-12-21 22:24:32 +01:00
name = "[[ .instance ]][[ $c.consul.suffix ]]"
2023-08-22 15:24:35 +02:00
connect {
gateway {
proxy {}
terminating {
2023-08-29 22:23:57 +02:00
[[- range $service, $def := .egress_gw.services ]]
2023-08-22 15:24:35 +02:00
service {
name = [[ $service | toJSON ]]
2023-08-29 22:23:57 +02:00
[[- range $k, $v := $def ]]
2023-08-22 15:24:35 +02:00
[[ $k ]] = [[ $v | toJSON ]]
2023-08-29 22:23:57 +02:00
[[- end ]]
2023-08-22 15:24:35 +02:00
}
2023-08-29 22:23:57 +02:00
[[- end ]]
2023-08-22 15:35:50 +02:00
}
2023-08-22 15:24:35 +02:00
}
sidecar_task {
2023-12-21 22:24:32 +01:00
[[ template "common/resources" $c.consul.connect.resources ]]
2023-08-22 15:24:35 +02:00
}
}
}
# Dummy task to configure custom CA certificates
# Needed because template is not supported in sidecar_task
2023-08-22 15:35:50 +02:00
task "ca-certs" {
2023-08-22 15:24:35 +02:00
driver = "exec"
config {
command = "/bin/true"
}
2023-08-22 15:35:50 +02:00
# The task will just quit immediatly, mark it as a prestart hook
2023-08-22 15:24:35 +02:00
lifecycle {
hook = "prestart"
}
[[- range $k, $v := .egress_gw.ca_certs ]]
template {
data =<<_EOF
[[ $v ]]
_EOF
destination = "${NOMAD_ALLOC_DIR}/data/[[ $k ]].crt"
}
2023-08-22 15:35:50 +02:00
[[- end ]]
2023-08-22 15:24:35 +02:00
# Give just enough resources
resources {
cpu = 10
memory = 10
memory_max = 20
}
}
}
}
# vim: syntax=hcl