Skip to content

Instantly share code, notes, and snippets.

@Neutrollized
Last active January 28, 2023 04:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neutrollized/1494efb1bee437ba982058dd4d8250e0 to your computer and use it in GitHub Desktop.
Save Neutrollized/1494efb1bee437ba982058dd4d8250e0 to your computer and use it in GitHub Desktop.
Medium: Getting started with HashiCorp Nomad just got easier in v1.4
job "redis-client" {
datacenters = ["gcp-test"]
group "redis" {
count = 1
task "client" {
driver = "docker"
template {
destination = "${NOMAD_SECRETS_DIR}/redis_password.vars"
env = true
change_mode = "restart"
data = <<EOF
{{- with nomadVar "nomad/jobs/redis-client" -}}
REDISCLI_AUTH = {{ .rediscli_password }}
{{- end -}}
EOF
}
template {
destination = "${NOMAD_TASK_DIR}/service.vars"
env = true
change_mode = "restart"
data = <<EOF
{{- range nomadService "redis-server" -}}
REDIS_SERVER_HOST={{ .Address }}
REDIS_SERVER_PORT={{ .Port }}
{{- end -}}
EOF
}
config {
image = "redis:7.0.7-alpine"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment