-
Notifications
You must be signed in to change notification settings - Fork 0
/
psc-admin-portal.nomad.tpl
316 lines (274 loc) · 10.2 KB
/
psc-admin-portal.nomad.tpl
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/*
* Copyright © 2022-2024 Agence du Numérique en Santé (ANS) (https://esante.gouv.fr)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
job "psc-admin-portal" {
datacenters = ["${datacenter}"]
type = "service"
namespace = "${nomad_namespace}"
vault {
policies = ["psc-ecosystem"]
change_mode = "signal"
change_signal = "SIGUSR1"
}
group "psc-admin-portal" {
count = "1"
restart {
attempts = 3
delay = "60s"
interval = "1h"
mode = "fail"
}
update {
max_parallel = 1
min_healthy_time = "30s"
progress_deadline = "5m"
healthy_deadline = "2m"
}
network {
port "https" {
to = 443
}
port "http" {
to = 80
}
}
task "portal-server" {
driver = "docker"
config {
image = "${artifact.image}:${artifact.tag}"
ports = ["https","http"]
mount {
type = "bind"
target = "/usr/local/apache2/conf/sec-psc/whitelist.conf"
source = "local/whitelist.conf"
readonly = true
}
mount {
type = "bind"
target = "/usr/local/apache2/conf/sec-psc/service-addresses.conf"
source = "local/service-addresses.conf"
readonly = true
}
mount {
type = "bind"
target = "/etc/pwd"
source = "secrets/pwd"
readonly = false
}
mount {
type = "bind"
target = "/usr/local/apache2/conf/sec-psc/sec-psc.cert"
source = "secrets/sec-psc.cert"
readonly = false
}
mount {
type = "bind"
target = "/usr/local/apache2/conf/sec-psc/sec-psc.key"
source = "secrets/sec-psc.key"
readonly = false
}
}
resources {
cpu = 300
memory = 1024
}
template {
data = <<EOH
{{ with secret "psc-ecosystem/${nomad_namespace}/admin-portal"}}
HOSTNAME={{.Data.data.hostname}}
PROTOCOL=https
PSC_HOST={{.Data.data.psc_host}}
CLIENT_ID={{.Data.data.client_id}}
CLIENT_SECRET={{.Data.data.client_secret}}
{{end}}
EOH
change_mode="restart"
destination = "secrets/front.env"
env = true
}
template {
data = <<EOH
{{ with secret "psc-ecosystem/${nomad_namespace}/admin-portal"}}{{.Data.data.srv_tls_keypass}}{{end}}
EOH
destination = "secrets/pwd"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
{{ with secret "psc-ecosystem/${nomad_namespace}/admin-portal"}}{{.Data.data.srv_tls_certificate}}{{end}}
EOH
destination = "secrets/sec-psc.cert"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
{{ with secret "psc-ecosystem/${nomad_namespace}/admin-portal"}}{{.Data.data.srv_tls_key}}{{end}}
EOH
destination = "secrets/sec-psc.key"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
# This will be bind_mounted, while the real data will be included so that httpd
# sees the new content when graceful-reloaded
include /local/service-addresses.data.conf
EOH
destination = "local/service-addresses.conf"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
# For each variable, a guard is added
# so that configuration remains parseable even if services are not found in consul
# The guard is a hack replacing non-existing variable value test
# for conditional configuration a la IfDefine
Define PS_API_ADDRESS "{{ range service "${nomad_namespace}-psc-api-maj-v2" }}{{.Address}}{{ end }}"
Define TEST_PS_API_ADDRESS{{ range service "${nomad_namespace}-psc-api-maj-v2" }}{{.Address}}{{ end }}
<IfDefine TEST_PS_API_ADDRESS>
Define PS_API_ADDRESS unknown
</IfDefine>
Define PS_API_PORT {{ range service "${nomad_namespace}-psc-api-maj-v2" }}{{.Port}}{{ end }}
Define TEST_PS_API_PORT{{ range service "${nomad_namespace}-psc-api-maj-v2" }}{{.Port}}{{ end }}
<IfDefine TEST_PS_API_PORT>
Define PS_API_PORT 00
</IfDefine>
Define TOGGLE_ADDRESS {{ range service "${nomad_namespace}-psc-toggle-manager" }}{{.Address}}{{ end }}
Define TEST_TOGGLE_ADDRESS{{ range service "${nomad_namespace}-psc-toggle-manager" }}{{.Address}}{{ end }}
<IfDefine TEST_TOGGLE_ADDRESS>
Define TOGGLE_ADDRESS unknown
</IfDefine>
Define TOGGLE_PORT {{ range service "${nomad_namespace}-psc-toggle-manager" }}{{.Port}}{{ end }}
Define TEST_TOGGLE_PORT{{ range service "${nomad_namespace}-psc-toggle-manager" }}{{.Port}}{{ end }}
<IfDefine TEST_TOGGLE_PORT>
Define TOGGLE_PORT 00
</IfDefine>
Define PSCLOAD_ADDRESS {{ range service "${nomad_namespace}-pscload" }}{{.Address}}{{ end }}
Define TEST_PSCLOAD_ADDRESS{{ range service "${nomad_namespace}-pscload" }}{{.Address}}{{ end }}
<IfDefine TEST_PSCLOAD_ADDRESS>
Define PSCLOAD_ADDRESS unknown
</IfDefine>
Define PSCLOAD_PORT {{ range service "${nomad_namespace}-pscload" }}{{.Port}}{{ end }}
Define TEST_PSCLOAD_PORT{{ range service "${nomad_namespace}-pscload" }}{{.Port}}{{ end }}
<IfDefine TEST_PSCLOAD_PORT>
Define PSCLOAD_PORT 00
</IfDefine>
Define PSCEXTRACT_ADDRESS {{ range service "${nomad_namespace}-pscextract" }}{{.Address}}{{ end }}
Define TEST_PSCEXTRACT_ADDRESS{{ range service "${nomad_namespace}-pscextract" }}{{.Address}}{{ end }}
<IfDefine TEST_PSCEXTRACT_ADDRESS>
Define PSCEXTRACT_ADDRESS unknown
</IfDefine>
Define PSCEXTRACT_PORT {{ range service "${nomad_namespace}-pscextract" }}{{.Port}}{{ end }}
Define TEST_PSCEXTRACT_PORT{{ range service "${nomad_namespace}-pscextract" }}{{.Port}}{{ end }}
<IfDefine TEST_PSCEXTRACT_PORT>
Define PSCEXTRACT_PORT 00
</IfDefine>
Define ALERT_MANAGER_ADDRESS {{ range service "${nomad_namespace}-psc-alertmanager" }}{{.Address}}{{ end }}
Define TEST_ALERT_MANAGER_ADDRESS{{ range service "${nomad_namespace}-psc-alertmanager" }}{{.Address}}{{ end }}
<IfDefine TEST_ALERT_MANAGER_ADDRESS>
Define ALERT_MANAGER_ADDRESS unknown
</IfDefine>
Define ALERT_MANAGER_PORT {{ range service "${nomad_namespace}-psc-alertmanager" }}{{.Port}}{{ end }}
Define TEST_ALERT_MANAGER_PORT{{ range service "${nomad_namespace}-psc-alertmanager" }}{{.Port}}{{ end }}
<IfDefine TEST_ALERT_MANAGER_PORT>
Define ALERT_MANAGER_PORT 00
</IfDefine>
Define KIBANA_ADDRESS {{ range service "${nomad_namespace}-kibana" }}{{.Address}}{{ end }}
Define TEST_KIBANA_ADDRESS{{ range service "${nomad_namespace}-kibana" }}{{.Address}}{{ end }}
<IfDefine TEST_KIBANA_ADDRESS>
Define KIBANA_ADDRESS unknown
</IfDefine>
Define KIBANA_PORT {{ range service "${nomad_namespace}-kibana" }}{{.Port}}{{ end }}
Define TEST_KIBANA_PORT{{ range service "${nomad_namespace}-kibana" }}{{.Port}}{{ end }}
<IfDefine TEST_KIBANA_PORT>
Define KIBANA_PORT 00
</IfDefine>
Define PROMETHEUS_ADDRESS {{ range service "${nomad_namespace}-psc-prometheus" }}{{.Address}}{{ end }}
Define TEST_PROMETHEUS_ADDRESS{{ range service "${nomad_namespace}-psc-prometheus" }}{{.Address}}{{ end }}
<IfDefine TEST_PROMETHEUS_ADDRESS>
Define PROMETHEUS_ADDRESS unknown
</IfDefine>
Define PROMETHEUS_PORT {{ range service "${nomad_namespace}-psc-prometheus" }}{{.Port}}{{ end }}
Define TEST_PROMETHEUS_PORT{{ range service "${nomad_namespace}-psc-prometheus" }}{{.Port}}{{ end }}
<IfDefine TEST_PROMETHEUS_PORT>
Define PROMETHEUS_PORT 00
</IfDefine>
Define RABBIT_MQ_ADDRESS {{ range service "${nomad_namespace}-psc-rabbitmq-management" }}{{.Address}}{{ end }}
Define TEST_RABBIT_MQ_ADDRESS{{ range service "${nomad_namespace}-psc-rabbitmq-management" }}{{.Address}}{{ end }}
<IfDefine TEST_RABBIT_MQ_ADDRESS>
Define RABBIT_MQ_ADDRESS 00
</IfDefine>
Define RABBIT_MQ_PORT {{ range service "${nomad_namespace}-psc-rabbitmq-management" }}{{.Port}}{{ end }}
Define TEST_RABBIT_MQ_PORT{{ range service "${nomad_namespace}-psc-rabbitmq-management" }}{{.Port}}{{ end }}
<IfDefine TEST_RABBIT_MQ_PORT>
Define RABBIT_MQ_PORT 00
</IfDefine>
Define AMAR_CONNECTOR_ADDRESS {{ range service "${nomad_namespace}-async-listener" }}{{.Address}}{{ end }}
Define TEST_AMAR_CONNECTOR_ADDRESS{{ range service "${nomad_namespace}-async-listener" }}{{.Address}}{{ end }}
<IfDefine TEST_AMAR_CONNECTOR_ADDRESS>
Define AMAR_CONNECTOR_ADDRESS 00
</IfDefine>
Define AMAR_CONNECTOR_PORT {{ range service "${nomad_namespace}-async-listener" }}{{.Port}}{{ end }}
Define TEST_AMAR_CONNECTOR_PORT{{ range service "${nomad_namespace}-async-listener" }}{{.Port}}{{ end }}
<IfDefine TEST_AMAR_CONNECTOR_PORT>
Define AMAR_CONNECTOR_PORT 00
</IfDefine>
EOH
destination = "local/service-addresses.data.conf"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
# This will be bind_mounted, while the real data will be included so that httpd
# sees the new content when graceful-reloaded
include /local/whitelist.data.conf
EOH
destination = "local/whitelist.conf"
change_mode = "signal"
change_signal = "SIGUSR1"
}
template {
data = <<EOH
{{ with secret "psc-ecosystem/${nomad_namespace}/admin-portal/whitelist" }}
{{range $k, $v := .Data.data }}
# Some rights for {{ $k }}
Require claim SubjectNameID:{{ $v }}
{{ end}}
{{ end }}
EOH
destination = "local/whitelist.data.conf"
change_mode = "signal"
change_signal = "SIGUSR1"
}
service {
name = "$\u007BNOMAD_NAMESPACE\u007D-$\u007BNOMAD_JOB_NAME\u007D"
tags = ["urlprefix-$\u007BHOSTNAME\u007D/ proto=tcp+sni"]
port = "https"
check {
type = "http"
path = "/"
port = "http"
interval = "30s"
timeout = "2s"
failures_before_critical = 5
}
}
}
}
}