aboutsummaryrefslogtreecommitdiff
path: root/cluster/prod/app/core/deploy/core-system.hcl
blob: 6ece3d6ecab1e913fa27d9143bb8b9142bf50569 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
job "core" {
  datacenters = ["orion", "neptune", "scorpio"]
  type = "system"
  priority = 90

  update {
    max_parallel = 1
    stagger = "5m"
  }

  group "diplonat" {
    task "diplonat" {
      driver = "docker"

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

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

      template {
        data = "{{ key \"secrets/consul/consul.crt\" }}"
        destination = "secrets/consul.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
DIPLONAT_REFRESH_TIME=60
DIPLONAT_EXPIRATION_TIME=300
DIPLONAT_CONSUL_NODE_NAME={{ env "attr.unique.hostname" }}
DIPLONAT_CONSUL_URL=https://consul.service.prod.consul:8501
DIPLONAT_CONSUL_TLS_SKIP_VERIFY=true
DIPLONAT_CONSUL_CLIENT_CERT=/etc/diplonat/consul-client.crt
DIPLONAT_CONSUL_CLIENT_KEY=/etc/diplonat/consul-client.key
RUST_LOG=debug
EOH
        destination = "secrets/env"
        env = true
      }

      resources {
        memory = 100
        memory_max = 200
      }
    }
  }

  group "tricot" {
    constraint {
      distinct_property = "${meta.site}"
      value = "1"
    }

    network {
      port "http_port" { static = 80 }
      port "https_port" { static = 443 }
      port "metrics_port" { static = 9334 }
    }

    task "server" {
      driver = "docker"

      config {
        image = "lxpz/amd64_tricot:47"
        network_mode = "host"
        readonly_rootfs = true
        ports = [ "http_port", "https_port" ]
        volumes = [
          "secrets:/etc/tricot",
        ]
      }

      resources {
        cpu = 1000
        memory = 200
        memory_max = 500
      }

      restart {
        interval = "5m"
        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
TRICOT_NODE_NAME={{ env "attr.unique.hostname" }}
TRICOT_LETSENCRYPT_EMAIL=prod-sysadmin@deuxfleurs.fr
TRICOT_ENABLE_COMPRESSION=true
TRICOT_CONSUL_HOST=https://consul.service.prod.consul:8501
TRICOT_CONSUL_TLS_SKIP_VERIFY=true
TRICOT_CONSUL_CLIENT_CERT=/etc/tricot/consul-client.crt
TRICOT_CONSUL_CLIENT_KEY=/etc/tricot/consul-client.key
TRICOT_HTTP_BIND_ADDR=[::]:80
TRICOT_HTTPS_BIND_ADDR=[::]:443
TRICOT_METRICS_BIND_ADDR=[::]:9334
RUST_LOG=tricot=debug
EOH
        destination = "secrets/env"
        env = true
      }

      service {
        name = "tricot-http"
        port = "http_port"
        tags = [ "(diplonat (tcp_port 80))", "${meta.site}" ]
        address_mode = "host"
      }

      service {
        name = "tricot-https"
        port = "https_port"
        tags = [
          "(diplonat (tcp_port 443))",
          "${meta.site}",
          "d53-aaaa ${meta.site}.site.deuxfleurs.fr",
          "d53-a global.site.deuxfleurs.fr",
          "d53-aaaa global.site.deuxfleurs.fr",
        ]
        address_mode = "host"
      }

      service {
        name = "tricot-metrics"
        port = "metrics_port"
        address_mode = "host"
      }
    }
  }

  group "bottin" {
    constraint {
      distinct_property = "${meta.site}"
      value = "1"
    }

    network {
      port "ldap_port" {
        static = 389
        to = 389
      }
    }

    task "bottin" {
      driver = "docker"
      config {
        image = "dxflrs/bottin:7h18i30cckckaahv87d3c86pn4a7q41z"
        network_mode = "host"
        readonly_rootfs = true
        ports = [ "ldap_port" ]
        volumes = [
          "secrets/config.json:/config.json",
          "secrets:/etc/bottin",
        ]
      }

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

      resources {
        memory = 100
        memory_max = 200
      }

      template {
        data = file("../config/bottin/config.json.tpl")
        destination = "secrets/config.json"
      }

      template {
        data = "{{ key \"secrets/consul/consul.crt\" }}"
        destination = "secrets/consul.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
CONSUL_HTTP_ADDR=https://consul.service.prod.consul:8501
CONSUL_HTTP_SSL=true
CONSUL_CACERT=/etc/bottin/consul.crt
CONSUL_CLIENT_CERT=/etc/bottin/consul-client.crt
CONSUL_CLIENT_KEY=/etc/bottin/consul-client.key
EOH
        destination = "secrets/env"
        env = true
      }

      service {
        tags = [ "${meta.site}" ]
        port = "ldap_port"
        address_mode = "host"
        name = "bottin"
        check {
          type = "tcp"
          port = "ldap_port"
          interval = "60s"
          timeout = "5s"
          check_restart {
            limit = 3
            grace = "90s"
            ignore_warnings = false
          }
        }
      }
    }
  }
}