aboutsummaryrefslogtreecommitdiff
path: root/cluster/prod/app/core/deploy/d53.hcl
blob: 74e18d5f859490ce50f992523848c8ea9d895263 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
job "core-d53" {
  datacenters = ["neptune", "scorpio", "bespin"]
  type = "service"
  priority = 90

  group "D53" {
    count = 1

    task "d53" {
      driver = "docker"

      config {
        image = "lxpz/amd64_d53:4"
        network_mode = "host"
        readonly_rootfs = true
        volumes = [
          "secrets:/etc/d53",
        ]
      }

      resources {
        cpu = 100
        memory = 100
      }

      restart {
        interval = "3m"
        attempts = 10
        delay    = "15s"
        mode     = "delay"
      }

      template {
        data = "{{ key \"secrets/consul/consul-ca.crt\" }}"
        destination = "secrets/consul-ca.crt"
      }

      template {
        data = "{{ key \"secrets/consul/consul-client.crt\" }}"
        destination = "secrets/consul-client.crt"
      }

      template {
        data = "{{ key \"secrets/consul/consul-client.key\" }}"
        destination = "secrets/consul-client.key"
      }

      template {
        data = <<EOH
D53_CONSUL_HOST=https://localhost:8501
D53_CONSUL_CA_CERT=/etc/d53/consul-ca.crt
D53_CONSUL_CLIENT_CERT=/etc/d53/consul-client.crt
D53_CONSUL_CLIENT_KEY=/etc/d53/consul-client.key
D53_PROVIDERS=deuxfleurs.fr:gandi
D53_GANDI_API_KEY={{ key "secrets/d53/gandi_api_key" }}
D53_ALLOWED_DOMAINS=deuxfleurs.fr
RUST_LOG=d53=info
EOH
        destination = "secrets/env"
        env = true
      }
    }
  }

  # Dummy task for Gitea (still on an external VM), runs on any bespin node
  # and allows D53 to automatically update the A record for git.deuxfleurs.fr
  # to the IPv4 address of the bespin site (that changes occasionnaly)
  group "gitea-dummy" {
    count = 1

    network {
      port "dummy" {
        to = 999
      }
    }

    task "main" {
      driver = "docker"

      constraint {
        attribute = "${meta.site}"
        operator = "="
        value = "bespin"
      }

      config {
        image = "alpine"
        command = "sh"
        args = ["-c", "while true; do echo x; sleep 60; done"]
        ports = [ "dummy" ]
      }

      service {
        name = "gitea-dummy"
        port = "dummy"
        tags = [
          "d53-a git.deuxfleurs.fr",
        ]
      }
    }
  }
}