egress-gateway/egress-gateway.nomad.hcl

72 lines
1.5 KiB
HCL
Raw Normal View History

2023-08-22 15:24:35 +02:00
job "egress-gateway" {
2023-08-25 00:53:56 +02:00
[[ template "common/job_start.tpl" .nomad ]]
2023-08-22 15:24:35 +02:00
group "egress-gateway" {
network {
mode = "bridge"
}
# Terminating gateway definition
service {
2023-08-22 15:35:50 +02:00
name = "egress-gateway[[ .env.suffix ]]"
2023-08-22 15:24:35 +02:00
connect {
gateway {
proxy {}
terminating {
[[- range $service, $def := .egress_gw.services ]]
service {
name = [[ $service | toJSON ]]
2023-08-22 15:35:50 +02:00
[[- range $k, $v := $def ]]
2023-08-22 15:24:35 +02:00
[[ $k ]] = [[ $v | toJSON ]]
[[- end ]]
}
[[- end ]]
2023-08-22 15:35:50 +02:00
}
2023-08-22 15:24:35 +02:00
}
sidecar_task {
config {
# Access the CA certificate
volumes = ["../alloc/data:/data"]
}
2023-08-22 15:26:42 +02:00
[[ template "common/resources.tpl" .envoy ]]
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