Skip to content

Instantly share code, notes, and snippets.

@Neutrollized
Created January 25, 2023 18:59
Show Gist options
  • Save Neutrollized/d42a83411a8617bbac53f80da8bc3667 to your computer and use it in GitHub Desktop.
Save Neutrollized/d42a83411a8617bbac53f80da8bc3667 to your computer and use it in GitHub Desktop.
Medium: Getting started with HashiCorp Nomad just got easier in v1.4
job "redis-server" {
datacenters = ["gcp-test"]
group "redis" {
count = 2
network {
port "db" { to = 6379 }
}
task "server" {
driver = "docker"
template {
destination = "${NOMAD_SECRETS_DIR}/env.vars"
env = true
change_mode = "restart"
data = <<EOF
{{- with nomadVar "nomad/jobs/redis-server/redis/server" -}}
REDIS_PASSWORD = {{ .password }}
{{- end -}}
EOF
}
config {
image = "redis:7.0.7-alpine"
args = ["--requirepass", "${REDIS_PASSWORD}"]
ports = ["db"]
}
}
service {
name = "redis-server"
port = "db"
provider = "nomad"
tags = ["redis", "server"]
check {
type = "tcp"
interval = "30s"
timeout = "5s"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment