diff --git a/services/nomad/apps/alps.nomad b/services/nomad/apps/alps.nomad index af960cc..ebaf97b 100644 --- a/services/nomad/apps/alps.nomad +++ b/services/nomad/apps/alps.nomad @@ -12,12 +12,14 @@ job "alps" { } service { - name = "alps" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "alps.s.voidlinux.org alps.voidlinux.org" - } + provider = "nomad" + name = "alps" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=alps.s.voidlinux.org alps.voidlinux.org", + ] } task "alps" { diff --git a/services/nomad/apps/debuginfod.nomad b/services/nomad/apps/debuginfod.nomad index 4cdd413..e70c8f5 100644 --- a/services/nomad/apps/debuginfod.nomad +++ b/services/nomad/apps/debuginfod.nomad @@ -26,12 +26,14 @@ job "debuginfod" { } service { - name = "debuginfod" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "debuginfod.s.voidlinux.org debuginfod.voidlinux.org" - } + provider = "nomad" + name = "debuginfod" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=debuginfod.s.voidlinux.org debuginfod.voidlinux.org", + ] check { type = "http" diff --git a/services/nomad/apps/devspace.nomad b/services/nomad/apps/devspace.nomad index b086aa8..025ca30 100644 --- a/services/nomad/apps/devspace.nomad +++ b/services/nomad/apps/devspace.nomad @@ -27,12 +27,15 @@ job "devspace" { } service { - name = "devspace-sftp" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "devspace-sftp.voidlinux.org" - } + provider = "nomad" + name = "devspace-sftp" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=devspace-sftp.voidlinux.org", + ] + check { type = "http" port = 8081 @@ -121,12 +124,14 @@ EOF } service { - name = "devspace" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "devspace.voidlinux.org" - } + provider = "nomad" + name = "devspace" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=devspace.voidlinux.org", + ] } task "nginx" { diff --git a/services/nomad/apps/etherpad.nomad b/services/nomad/apps/etherpad.nomad index e08dd8c..0310e9d 100644 --- a/services/nomad/apps/etherpad.nomad +++ b/services/nomad/apps/etherpad.nomad @@ -10,12 +10,14 @@ job "etherpad" { } service { - name = "pad" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "pad.voidlinux.org" - } + provider = "nomad" + name = "pad" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=pad.voidlinux.org", + ] } volume "etherpad" { diff --git a/services/nomad/apps/infradocs.nomad b/services/nomad/apps/infradocs.nomad index fc6a953..be41fd5 100644 --- a/services/nomad/apps/infradocs.nomad +++ b/services/nomad/apps/infradocs.nomad @@ -14,12 +14,14 @@ job "infradocs" { } service { - name = "infradocs" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "infradocs.voidlinux.org" - } + provider = "nomad" + name = "infradocs" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=infradocs.voidlinux.org", + ] check { type = "http" diff --git a/services/nomad/apps/ircbot.nomad b/services/nomad/apps/ircbot.nomad index 08da035..fa76845 100644 --- a/services/nomad/apps/ircbot.nomad +++ b/services/nomad/apps/ircbot.nomad @@ -14,12 +14,14 @@ job "ircbot" { } service { - name = "ircbot" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "ircbot.voidlinux.org" - } + provider = "nomad" + name = "ircbot" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=ircbot.voidlinux.org", + ] } task "ircbot" { diff --git a/services/nomad/apps/man-cgi.nomad b/services/nomad/apps/man-cgi.nomad index 43570d2..f3ec41d 100644 --- a/services/nomad/apps/man-cgi.nomad +++ b/services/nomad/apps/man-cgi.nomad @@ -25,12 +25,14 @@ job "man-cgi" { } service { - name = "man-cgi" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "man.voidlinux.org" - } + provider = "nomad" + name = "man-cgi" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=man.voidlinux.org", + ] } task "man-cgi" { diff --git a/services/nomad/apps/popcorn.nomad b/services/nomad/apps/popcorn.nomad index fa13ba7..6e78c1c 100644 --- a/services/nomad/apps/popcorn.nomad +++ b/services/nomad/apps/popcorn.nomad @@ -18,12 +18,14 @@ job "popcorn" { } service { - name = "popcorn" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "popcorn.voidlinux.org" - } + provider = "nomad" + name = "popcorn" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=popcorn.voidlinux.org", + ] } task "nginx" { diff --git a/services/nomad/apps/xq-api.nomad b/services/nomad/apps/xq-api.nomad index 90c0215..d7a9a76 100644 --- a/services/nomad/apps/xq-api.nomad +++ b/services/nomad/apps/xq-api.nomad @@ -25,12 +25,14 @@ job "xq-api" { } service { - name = "xq-api" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "xq-api.voidlinux.org" - } + provider = "nomad" + name = "xq-api" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=xq-api.voidlinux.org", + ] } task "xq-api" { diff --git a/services/nomad/infrastructure/nginx-sites/10-buildbot.conf b/services/nomad/infrastructure/nginx-sites/10-buildbot.conf index b812e2d..93c8376 100644 --- a/services/nomad/infrastructure/nginx-sites/10-buildbot.conf +++ b/services/nomad/infrastructure/nginx-sites/10-buildbot.conf @@ -12,20 +12,23 @@ server { proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-Host $host; +{{ $allocID := env "NOMAD_ALLOC_ID" }} +{{ range nomadService 1 $allocID "buildbot-www?ns=build" }} location / { - proxy_pass http://buildbot-www.service.consul:8010/; + proxy_pass http://{{ .Address }}:{{ .Port }}/; } location /sse/ { proxy_buffering off; - proxy_pass http://buildbot-www.service.consul:8010/sse/; + proxy_pass http://{{ .Address }}:{{ .Port }}//sse/; } location /ws { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; - proxy_pass http://buildbot-www.service.consul:8010/ws; + proxy_pass http://{{ .Address }}:{{ .Port }}/ws; proxy_read_timeout 6000s; } +{{ end }} } diff --git a/services/nomad/infrastructure/nginx-sites/10-proxy.conf b/services/nomad/infrastructure/nginx-sites/10-proxy.conf index a295c05..596685c 100644 --- a/services/nomad/infrastructure/nginx-sites/10-proxy.conf +++ b/services/nomad/infrastructure/nginx-sites/10-proxy.conf @@ -1,14 +1,18 @@ -{{ range services -}} -{{ range service (printf "%s~_agent" .Name) -}} -{{ if index .ServiceMeta "nginx_enable" -}} -{{ if not (scratch.Key .Name) -}} -{{ scratch.Set .Name "1" -}} +{{ range nomadServices "?ns=*" -}} +{{ range nomadService (printf "%s?ns=%s" .Name .Namespace) -}} +{{ if in .Tags "nginx_enable" -}} +{{ range $tag := .Tags -}} + {{ if $tag | contains "nginx_names=" -}} + {{ scratch.Set "names" ($tag | trimPrefix "nginx_names=") -}} + {{ break -}} + {{ end -}} +{{ end -}} server { include /etc/nginx/fragments/ssl.conf; listen 443 ssl; listen [::]:443 ssl; http2 on; - server_name {{ index .ServiceMeta "nginx_names" }}; + server_name {{ scratch.Get "names" }}; location / { proxy_set_header Host $host; @@ -20,4 +24,3 @@ server { {{ end -}} {{ end -}} {{ end -}} -{{ end -}} diff --git a/services/nomad/infrastructure/terrastate.nomad b/services/nomad/infrastructure/terrastate.nomad index 6a86cff..42b2668 100644 --- a/services/nomad/infrastructure/terrastate.nomad +++ b/services/nomad/infrastructure/terrastate.nomad @@ -26,12 +26,14 @@ job "terrastate" { } service { - name = "terrastate" - port = "http" - meta { - nginx_enable = "true" - nginx_names = "terrastate.s.voidlinux.org" - } + provider = "nomad" + name = "terrastate" + port = "http" + + tags = [ + "nginx_enable", + "nginx_names=terrastate.s.voidlinux.org", + ] check { type = "http"