2023-07-07 22:50:23 +00:00
|
|
|
job "redis-${name}" {
|
2022-03-14 22:56:06 +00:00
|
|
|
datacenters = ["dc1"]
|
|
|
|
type = "service"
|
2022-11-15 19:43:05 +00:00
|
|
|
priority = 80
|
2022-03-14 22:56:06 +00:00
|
|
|
|
|
|
|
group "cache" {
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
ephemeral_disk {
|
|
|
|
migrate = true
|
|
|
|
sticky = true
|
|
|
|
size = 300
|
|
|
|
}
|
|
|
|
|
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
|
2023-05-09 20:20:36 +00:00
|
|
|
port "tls" {}
|
2022-03-14 22:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
service {
|
2023-07-07 22:50:23 +00:00
|
|
|
name = "redis-${name}"
|
2022-11-21 00:24:00 +00:00
|
|
|
provider = "nomad"
|
2023-03-24 23:32:37 +00:00
|
|
|
port = "tls"
|
2022-03-14 22:56:06 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 04:45:01 +00:00
|
|
|
task "redis" {
|
2022-03-14 22:56:06 +00:00
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "redis:6"
|
2023-07-07 22:50:23 +00:00
|
|
|
args = ["redis-server", "--save", "60", "1", "--loglevel", "warning", "--dir", "$${NOMAD_ALLOC_DIR}/data"]
|
2022-03-14 22:56:06 +00:00
|
|
|
ports = ["main"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 100
|
2023-03-12 17:23:26 +00:00
|
|
|
memory = 128
|
|
|
|
memory_max = 512
|
2022-03-14 22:56:06 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-24 23:32:37 +00:00
|
|
|
|
|
|
|
task "stunnel" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "alpine:3.17"
|
|
|
|
ports = ["tls"]
|
2023-07-07 22:50:23 +00:00
|
|
|
args = ["/bin/sh", "$${NOMAD_TASK_DIR}/start.sh"]
|
2023-03-24 23:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 100
|
|
|
|
memory = 100
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
set -e
|
|
|
|
apk add stunnel
|
2023-07-07 22:50:23 +00:00
|
|
|
exec stunnel $${NOMAD_TASK_DIR}/stunnel.conf
|
2023-03-24 23:32:37 +00:00
|
|
|
EOF
|
2023-07-07 22:50:23 +00:00
|
|
|
destination = "$${NOMAD_TASK_DIR}/start.sh"
|
2023-03-24 23:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
syslog = no
|
|
|
|
foreground = yes
|
|
|
|
delay = yes
|
|
|
|
|
|
|
|
[redis_server]
|
|
|
|
|
|
|
|
accept = {{ env "NOMAD_PORT_tls" }}
|
|
|
|
connect = 127.0.0.1:6379
|
|
|
|
ciphers = PSK
|
|
|
|
PSKsecrets = {{ env "NOMAD_SECRETS_DIR" }}/stunnel_psk.txt
|
|
|
|
EOF
|
2023-07-07 22:50:23 +00:00
|
|
|
destination = "$${NOMAD_TASK_DIR}/stunnel.conf"
|
2023-03-24 23:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2023-07-07 22:50:23 +00:00
|
|
|
{{ with nomadVar "nomad/jobs/redis-${name}" -}}
|
2023-03-29 00:28:46 +00:00
|
|
|
{{ .allowed_psks }}
|
|
|
|
{{- end }}
|
2023-03-24 23:32:37 +00:00
|
|
|
EOF
|
2023-07-07 22:50:23 +00:00
|
|
|
destination = "$${NOMAD_SECRETS_DIR}/stunnel_psk.txt"
|
2023-03-24 23:32:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-14 22:56:06 +00:00
|
|
|
}
|
|
|
|
}
|