homelab-nomad/databases/redis.nomad

84 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

job "redis-${name}" {
datacenters = ["dc1"]
type = "service"
priority = 80
group "cache" {
count = 1
ephemeral_disk {
migrate = true
sticky = true
size = 300
}
network {
mode = "bridge"
port "tls" {}
}
service {
name = "redis-${name}"
provider = "nomad"
port = "tls"
}
2022-07-26 04:45:01 +00:00
task "redis" {
driver = "docker"
config {
image = "redis:6"
args = ["redis-server", "--save", "60", "1", "--loglevel", "warning", "--dir", "$${NOMAD_ALLOC_DIR}/data"]
ports = ["main"]
}
resources {
cpu = 100
2024-03-26 16:48:31 +00:00
memory = 64
memory_max = 512
}
}
task "stunnel" {
driver = "docker"
config {
image = "iamthefij/stunnel:latest"
args = ["$${NOMAD_TASK_DIR}/stunnel.conf"]
ports = ["tls"]
}
resources {
2024-03-26 16:48:31 +00:00
cpu = 50
memory = 15
}
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
destination = "$${NOMAD_TASK_DIR}/stunnel.conf"
}
template {
data = <<EOF
{{ with nomadVar "nomad/jobs/redis-${name}" -}}
2023-03-29 00:28:46 +00:00
{{ .allowed_psks }}
{{- end }}
EOF
destination = "$${NOMAD_SECRETS_DIR}/stunnel_psk.txt"
}
}
}
}