Skip to content

Commit 196c82e

Browse files
committed
various: nomad managed mirrors
1 parent c9d7ae7 commit 196c82e

8 files changed

Lines changed: 145 additions & 22 deletions

File tree

services/nomad/build/buildsync-dist.nomad

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ job "buildsync-dist" {
44
namespace = "build"
55

66
group "rsync" {
7-
count = 2
7+
count = 1
88

99
network { mode = "bridge" }
1010

11-
constraint {
12-
operator = "distinct_hosts"
13-
value = "true"
14-
}
15-
1611
volume "dist-pkgs" {
1712
type = "host"
1813
source = "dist_pkgs"

services/nomad/infrastructure/traefik.nomad

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
job "traefik" {
2-
datacenters = ["VOID-PROXY", "VOID"]
2+
datacenters = ["VOID-PROXY", "VOID-MIRROR"]
33
namespace = "infrastructure"
44
type = "system"
55
group "lb" {
@@ -20,11 +20,12 @@ job "traefik" {
2020
}
2121

2222
service {
23+
name = "traefik-${node.unique.name}"
2324
port = "http"
2425
tags = [
2526
"traefik.enable=true",
26-
"traefik.http.routers.proxy-lb.service=api@internal",
27-
"traefik.http.routers.proxy-lb.tls=true",
27+
"traefik.http.routers.traefik-${node.unique.name}.service=api@internal",
28+
"traefik.http.routers.traefik-${node.unique.name}.tls=true",
2829
]
2930
}
3031

services/nomad/mirror/mirror.nomad

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
job "mirror" {
2+
type = "system"
3+
datacenters = ["VOID-MIRROR"]
4+
namespace = "mirror"
5+
6+
group "http" {
7+
network {
8+
mode = "bridge"
9+
port "http" { to = 80 }
10+
}
11+
12+
volume "root-mirror" {
13+
type = "host"
14+
source = "root_mirror"
15+
read_only = true
16+
}
17+
18+
service {
19+
name = "mirror-${node.unique.name}"
20+
port = "http"
21+
tags = [
22+
"traefik.enable=true",
23+
"traefik.http.routers.mirror-${node.unique.name}.tls=true",
24+
"traefik.http.routers.mirror-${node.unique.name}.rule=HostRegexp(`repo.voidlinux.org`, `{subdomain:repo-[a-z]{2}}.voidlinux.org`)",
25+
]
26+
}
27+
28+
task "nginx" {
29+
driver = "docker"
30+
31+
config {
32+
image = "ghcr.io/void-linux/infra-nginx:v20210926rc01"
33+
}
34+
35+
volume_mount {
36+
volume = "root-mirror"
37+
destination = "/srv/www"
38+
}
39+
}
40+
}
41+
}

services/nomad/mirror/sync.nomad

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
job "sync" {
2+
type = "system"
3+
datacenters = ["VOID-MIRROR"]
4+
namespace = "mirror"
5+
6+
group "rsync" {
7+
count = 1
8+
9+
network { mode = "bridge" }
10+
11+
volume "root-mirror" {
12+
type = "host"
13+
source = "root_mirror"
14+
read_only = false
15+
}
16+
17+
task "rsync" {
18+
leader = true
19+
driver = "docker"
20+
21+
vault {
22+
policies = ["void-secrets-buildsync"]
23+
}
24+
25+
config {
26+
image = "eeacms/rsync"
27+
args = ["client"]
28+
}
29+
30+
env {
31+
CRON_TASK_1="* * * * * flock -n /run/sync.lock rsync -vurk --filter '- .*' --delete-after -e 'ssh -i /secrets/id_rsa -o UserKnownHostsFile=/local/known_hosts' void-buildsync@a-hel-fi.node.consul:/srv/www/void-repo/ /mirror/"
32+
}
33+
34+
resources {
35+
memory = 1000
36+
}
37+
38+
volume_mount {
39+
volume = "root-mirror"
40+
destination = "/mirror"
41+
}
42+
43+
template {
44+
data = <<EOF
45+
{{- with secret "secret/buildsync/ssh" -}}
46+
{{.Data.private_key}}
47+
{{- end -}}
48+
EOF
49+
destination = "secrets/id_rsa"
50+
perms = "0400"
51+
}
52+
53+
template {
54+
data = <<EOF
55+
a-hel-fi.node.consul ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIW8voCZh9nQpdx3fAsvfZO4mCYv0/OUVNPF9A/GsHtX
56+
EOF
57+
destination = "local/known_hosts"
58+
}
59+
}
60+
}
61+
}

terraform/do/.terraform.lock.hcl

Lines changed: 18 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/do/dns.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ resource "digitalocean_record" "catchall" {
236236
# We have a few mirrors that get special names, those go here. #
237237
################################################################
238238

239+
resource "digitalocean_record" "repo_fi" {
240+
domain = digitalocean_domain.voidlinux_org.name
241+
type = "CNAME"
242+
name = "repo-fi.${digitalocean_domain.voidlinux_org.name}."
243+
value = "b-hel-fi.m.${digitalocean_domain.voidlinux_org.name}."
244+
}
245+
246+
resource "digitalocean_record" "repo_us" {
247+
domain = digitalocean_domain.voidlinux_org.name
248+
type = "CNAME"
249+
name = "repo-us.${digitalocean_domain.voidlinux_org.name}."
250+
value = "a-mci-us.m.${digitalocean_domain.voidlinux_org.name}."
251+
}
252+
239253
resource "digitalocean_record" "repo_alpha_de" {
240254
domain = digitalocean_domain.voidlinux_org.name
241255
type = "CNAME"

terraform/do/versions.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ terraform {
22
required_providers {
33
digitalocean = {
44
source = "digitalocean/digitalocean"
5+
version = ">= 2.12.0"
56
}
67
}
78
required_version = ">= 0.13"

terraform/hashistack/nomad_namespaces.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ resource "nomad_namespace" "build" {
2222
name = "build"
2323
description = "Home of build related tasks"
2424
}
25+
26+
resource "nomad_namespace" "mirror" {
27+
name = "mirror"
28+
description = "Home of mirror related tasks"
29+
}

0 commit comments

Comments
 (0)