Created
January 25, 2023 18:59
-
-
Save Neutrollized/d42a83411a8617bbac53f80da8bc3667 to your computer and use it in GitHub Desktop.
Medium: Getting started with HashiCorp Nomad just got easier in v1.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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