egress-gateway/egress-gateway.nomad.hcl

79 lines
1.8 KiB
HCL
Raw Permalink Normal View History

2023-10-08 16:31:31 +02:00
[[ $c := merge .egress_gw . -]]
2023-08-22 15:24:35 +02:00
2024-02-05 14:59:35 +01:00
job "[[ .instance ]]" {
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" {
2024-02-05 14:59:35 +01:00
count = [[ $c.count ]]
2023-08-22 15:24:35 +02:00
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 {
2024-02-05 14:59:35 +01:00
name = "[[ $service ]]"
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 {
logs {
disabled = [[ .consul.connect.logs.disabled | ternary "true" "false" ]]
}
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" {
# Use docker instead of exec as it's broken on EL8. See https://github.com/hashicorp/nomad/issues/20212
driver = "docker"
2023-08-22 15:24:35 +02:00
config {
image = "[[ .docker.repo ]][[ .docker.base_images.alpine.image ]]"
readonly_rootfs = true
pids_limit = 10
command = "/bin/true"
2023-08-22 15:24:35 +02:00
}
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