Add nomad services to nomad zone using hosts in blocky

This commit is contained in:
IamTheFij 2023-03-27 15:20:50 -07:00
parent a748adbab0
commit f17dec7b57
2 changed files with 22 additions and 2 deletions

View File

@ -86,6 +86,23 @@ job "blocky" {
max = "20s" max = "20s"
} }
} }
template {
data = <<EOF
{{ range nomadServices }}
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") .Name -}}
{{ .Address }} {{ .Name }}.nomad
{{- end }}
{{- end }}
EOF
destination = "${NOMAD_TASK_DIR}/nomad.hosts"
change_mode = "noop"
wait {
min = "10s"
max = "20s"
}
}
} }
task "redis-stunnel" { task "redis-stunnel" {

View File

@ -25,8 +25,6 @@ upstream:
conditional: conditional:
fallbackUpstream: false fallbackUpstream: false
mapping: mapping:
# TODO: Run a simple dns server that this can forward to where it's hosts are set by nomad-services
# consul: {{ env "attr.unique.network.ip-address" }}:8600
home.arpa: 192.168.2.1 home.arpa: 192.168.2.1
in-addr.arpa: 192.168.2.1 in-addr.arpa: 192.168.2.1
iot: 192.168.2.1 iot: 192.168.2.1
@ -34,6 +32,11 @@ conditional:
thefij: 192.168.2.1 thefij: 192.168.2.1
.: 192.168.2.1 .: 192.168.2.1
hostsFile:
filePath: {{ env "NOMAD_TASK_DIR" }}/nomad.hosts
hostsTTL: 30s
refreshPeriod: 30s
clientLookup: clientLookup:
upstream: 192.168.2.1 upstream: 192.168.2.1