Infra: Monitoring capability
[csit.git] / terraform-ci-infra / 1n_nmd / exporter / conf / nomad / exporter.hcl
1 job "${job_name}" {
2   # The "region" parameter specifies the region in which to execute the job.
3   # If omitted, this inherits the default region name of "global".
4   # region = "global"
5   #
6   # The "datacenters" parameter specifies the list of datacenters which should
7   # be considered when placing this task. This must be provided.
8   datacenters         = "${datacenters}"
9
10   # The "type" parameter controls the type of job, which impacts the scheduler's
11   # decision on placement. This configuration is optional and defaults to
12   # "service". For a full list of job types and their differences, please see
13   # the online documentation.
14   #
15   #     https://www.nomadproject.io/docs/jobspec/schedulers
16   #
17   type                = "system"
18
19   update {
20     # The "max_parallel" parameter specifies the maximum number of updates to
21     # perform in parallel. In this case, this specifies to update a single task
22     # at a time.
23     max_parallel      = 1
24
25     health_check      = "checks"
26
27     # The "min_healthy_time" parameter specifies the minimum time the allocation
28     # must be in the healthy state before it is marked as healthy and unblocks
29     # further allocations from being updated.
30     min_healthy_time  = "10s"
31
32     # The "healthy_deadline" parameter specifies the deadline in which the
33     # allocation must be marked as healthy after which the allocation is
34     # automatically transitioned to unhealthy. Transitioning to unhealthy will
35     # fail the deployment and potentially roll back the job if "auto_revert" is
36     # set to true.
37     healthy_deadline  = "3m"
38
39     # The "progress_deadline" parameter specifies the deadline in which an
40     # allocation must be marked as healthy. The deadline begins when the first
41     # allocation for the deployment is created and is reset whenever an allocation
42     # as part of the deployment transitions to a healthy state. If no allocation
43     # transitions to the healthy state before the progress deadline, the
44     # deployment is marked as failed.
45     progress_deadline = "10m"
46
47 %{ if use_canary }
48     # The "canary" parameter specifies that changes to the job that would result
49     # in destructive updates should create the specified number of canaries
50     # without stopping any previous allocations. Once the operator determines the
51     # canaries are healthy, they can be promoted which unblocks a rolling update
52     # of the remaining allocations at a rate of "max_parallel".
53     #
54     # Further, setting "canary" equal to the count of the task group allows
55     # blue/green deployments. When the job is updated, a full set of the new
56     # version is deployed and upon promotion the old version is stopped.
57     canary            = 1
58
59     # Specifies if the job should auto-promote to the canary version when all
60     # canaries become healthy during a deployment. Defaults to false which means
61     # canaries must be manually updated with the nomad deployment promote
62     # command.
63     auto_promote      = true
64
65     # The "auto_revert" parameter specifies if the job should auto-revert to the
66     # last stable job on deployment failure. A job is marked as stable if all the
67     # allocations as part of its deployment were marked healthy.
68     auto_revert       = true
69 %{ endif }
70   }
71
72   # The "group" stanza defines a series of tasks that should be co-located on
73   # the same Nomad client. Any task within a group will be placed on the same
74   # client.
75   #
76   #     https://www.nomadproject.io/docs/job-specification/group
77   #
78   group "prod-group1-exporter-amd64" {
79     # The constraint allows restricting the set of eligible nodes. Constraints
80     # may filter on attributes or client metadata.
81     #
82     #     https://www.nomadproject.io/docs/job-specification/constraint
83     #
84     constraint {
85       attribute       = "$${attr.cpu.arch}"
86       operator        = "!="
87       value           = "arm64"
88     }
89
90     # The "task" stanza creates an individual unit of work, such as a Docker
91     # container, web application, or batch processing.
92     #
93     #     https://www.nomadproject.io/docs/job-specification/task
94     #
95     task "prod-task1-${node_service_name}-amd64" {
96       # The "driver" parameter specifies the task driver that should be used to
97       # run the task.
98       driver          = "raw_exec"
99
100       # The "config" stanza specifies the driver configuration, which is passed
101       # directly to the driver to start the task. The details of configurations
102       # are specific to each driver, so please see specific driver
103       # documentation for more information.
104       config {
105         command       = "local/node_exporter-${node_version}.linux-amd64/node_exporter"
106       }
107
108       # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
109       # such as a file, tarball, or binary. Nomad downloads artifacts using the
110       # popular go-getter library, which permits downloading artifacts from a
111       # variety of locations using a URL as the input source.
112       #
113       #     https://www.nomadproject.io/docs/job-specification/artifact
114       #
115       artifact {
116         source        = "${node_url_amd64}"
117       }
118
119       # The service stanza instructs Nomad to register a service with Consul.
120       #
121       #     https://www.nomadproject.io/docs/job-specification/service
122       #
123       service {
124         name          = "${node_service_name}"
125         port          = "${node_service_name}"
126         check {
127           name        = "Node Exporter Check Live"
128           type        = "http"
129           path        = "/metrics"
130           interval    = "10s"
131           timeout     = "2s"
132         }
133       }
134
135       # The "resources" stanza describes the requirements a task needs to
136       # execute. Resource requirements include memory, network, cpu, and more.
137       # This ensures the task will execute on a machine that contains enough
138       # resource capacity.
139       #
140       #     https://www.nomadproject.io/docs/job-specification/resources
141       #
142       resources {
143         cpu           = 500
144         # The network stanza specifies the networking requirements for the task
145         # group, including the network mode and port allocations. When scheduling
146         # jobs in Nomad they are provisioned across your fleet of machines along
147         # with other jobs and services. Because you don't know in advance what host
148         # your job will be provisioned on, Nomad will provide your tasks with
149         # network configuration when they start up.
150         #
151         #     https://www.nomadproject.io/docs/job-specification/network
152         #
153         network {
154           port "${node_service_name}" {
155             static    = ${node_port}
156           }
157         }
158       }
159     }
160     task "prod-task2-${blackbox_service_name}-amd64" {
161       # The "driver" parameter specifies the task driver that should be used to
162       # run the task.
163       driver          = "exec"
164
165       # The "config" stanza specifies the driver configuration, which is passed
166       # directly to the driver to start the task. The details of configurations
167       # are specific to each driver, so please see specific driver
168       # documentation for more information.
169       config {
170         command       = "local/blackbox_exporter-${blackbox_version}.linux-amd64/blackbox_exporter"
171         args          = [
172           "--config.file=secrets/blackbox.yml"
173         ]
174       }
175
176       # The "template" stanza instructs Nomad to manage a template, such as
177       # a configuration file or script. This template can optionally pull data
178       # from Consul or Vault to populate runtime configuration data.
179       #
180       #     https://www.nomadproject.io/docs/job-specification/template
181       #
182       template {
183         change_mode     = "noop"
184         change_signal   = "SIGINT"
185         destination     = "secrets/blackbox.yml"
186         data            = <<EOH
187 modules:
188   http_2xx:
189     prober: http
190     timeout: 5s
191     http:
192       valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
193       no_follow_redirects: false
194       fail_if_ssl: false
195       fail_if_not_ssl: true
196       tls_config:
197         insecure_skip_verify: false
198       preferred_ip_protocol: "ip4"
199   icmp_v4:
200     prober: icmp
201     timeout: 5s
202     icmp:
203       preferred_ip_protocol: "ip4"
204   dns_udp:
205     prober: dns
206     timeout: 5s
207     dns:
208       query_name: "jenkins.fd.io"
209       query_type: "A"
210       valid_rcodes:
211       - NOERROR
212 EOH
213       }
214
215       # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
216       # such as a file, tarball, or binary. Nomad downloads artifacts using the
217       # popular go-getter library, which permits downloading artifacts from a
218       # variety of locations using a URL as the input source.
219       #
220       #     https://www.nomadproject.io/docs/job-specification/artifact
221       #
222       artifact {
223         source        = "${blackbox_url_amd64}"
224       }
225
226       # The service stanza instructs Nomad to register a service with Consul.
227       #
228       #     https://www.nomadproject.io/docs/job-specification/service
229       #
230       service {
231         name          = "${blackbox_service_name}"
232         port          = "${blackbox_service_name}"
233         tags          = [ "${blackbox_service_name}$${NOMAD_ALLOC_INDEX}" ]
234         check {
235           name        = "Blackbox Exporter Check Live"
236           type        = "http"
237           path        = "/metrics"
238           interval    = "10s"
239           timeout     = "2s"
240         }
241       }
242
243       # The "resources" stanza describes the requirements a task needs to
244       # execute. Resource requirements include memory, network, cpu, and more.
245       # This ensures the task will execute on a machine that contains enough
246       # resource capacity.
247       #
248       #     https://www.nomadproject.io/docs/job-specification/resources
249       #
250       resources {
251         cpu           = 500
252         # The network stanza specifies the networking requirements for the task
253         # group, including the network mode and port allocations. When scheduling
254         # jobs in Nomad they are provisioned across your fleet of machines along
255         # with other jobs and services. Because you don't know in advance what host
256         # your job will be provisioned on, Nomad will provide your tasks with
257         # network configuration when they start up.
258         #
259         #     https://www.nomadproject.io/docs/job-specification/network
260         #
261         network {
262           port "${blackbox_service_name}" {
263             static    = ${blackbox_port}
264           }
265         }
266       }
267     }
268
269     task "prod-task3-${cadvisor_service_name}-amd64" {
270       # The "driver" parameter specifies the task driver that should be used to
271       # run the task.
272       driver          = "docker"
273
274       # The "config" stanza specifies the driver configuration, which is passed
275       # directly to the driver to start the task. The details of configurations
276       # are specific to each driver, so please see specific driver
277       # documentation for more information.
278       config {
279         image         = "${cadvisor_image}"
280         volumes       = [
281           "/:/rootfs:ro",
282           "/var/run:/var/run:rw",
283           "/sys:/sys:ro",
284           "/var/lib/docker/:/var/lib/docker:ro",
285           "/cgroup:/cgroup:ro"
286         ]
287       }
288
289       # The service stanza instructs Nomad to register a service with Consul.
290       #
291       #     https://www.nomadproject.io/docs/job-specification/service
292       #
293       service {
294         name          = "${cadvisor_service_name}"
295         port          = "${cadvisor_service_name}"
296         check {
297           name        = "cAdvisor Check Live"
298           type        = "http"
299           path        = "/metrics"
300           interval    = "10s"
301           timeout     = "2s"
302         }
303       }
304
305       # The "resources" stanza describes the requirements a task needs to
306       # execute. Resource requirements include memory, network, cpu, and more.
307       # This ensures the task will execute on a machine that contains enough
308       # resource capacity.
309       #
310       #     https://www.nomadproject.io/docs/job-specification/resources
311       #
312       resources {
313         cpu           = 500
314         # The network stanza specifies the networking requirements for the task
315         # group, including the network mode and port allocations. When scheduling
316         # jobs in Nomad they are provisioned across your fleet of machines along
317         # with other jobs and services. Because you don't know in advance what host
318         # your job will be provisioned on, Nomad will provide your tasks with
319         # network configuration when they start up.
320         #
321         #     https://www.nomadproject.io/docs/job-specification/network
322         #
323         network {
324           port "${cadvisor_service_name}" {
325             static    = ${cadvisor_port}
326           }
327         }
328       }
329     }
330   }
331
332   group "prod-group1-exporter-arm64" {
333     # The constraint allows restricting the set of eligible nodes. Constraints
334     # may filter on attributes or client metadata.
335     #
336     #     https://www.nomadproject.io/docs/job-specification/constraint
337     #
338     constraint {
339       attribute       = "$${attr.cpu.arch}"
340       operator        = "=="
341       value           = "arm64"
342     }
343
344     # The "task" stanza creates an individual unit of work, such as a Docker
345     # container, web application, or batch processing.
346     #
347     #     https://www.nomadproject.io/docs/job-specification/task
348     #
349     task "prod-task1-${node_service_name}-arm64" {
350       # The "driver" parameter specifies the task driver that should be used to
351       # run the task.
352       driver          = "raw_exec"
353
354       # The "config" stanza specifies the driver configuration, which is passed
355       # directly to the driver to start the task. The details of configurations
356       # are specific to each driver, so please see specific driver
357       # documentation for more information.
358       config {
359         command       = "local/node_exporter-${node_version}.linux-arm64/node_exporter"
360       }
361
362       # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
363       # such as a file, tarball, or binary. Nomad downloads artifacts using the
364       # popular go-getter library, which permits downloading artifacts from a
365       # variety of locations using a URL as the input source.
366       #
367       #     https://www.nomadproject.io/docs/job-specification/artifact
368       #
369       artifact {
370         source        = "${node_url_arm64}"
371       }
372
373       # The service stanza instructs Nomad to register a service with Consul.
374       #
375       #     https://www.nomadproject.io/docs/job-specification/service
376       #
377       service {
378         name          = "${node_service_name}"
379         port          = "${node_service_name}"
380         check {
381           name        = "Node Exporter Check Live"
382           type        = "http"
383           path        = "/metrics"
384           interval    = "10s"
385           timeout     = "2s"
386         }
387       }
388
389       # The "resources" stanza describes the requirements a task needs to
390       # execute. Resource requirements include memory, network, cpu, and more.
391       # This ensures the task will execute on a machine that contains enough
392       # resource capacity.
393       #
394       #     https://www.nomadproject.io/docs/job-specification/resources
395       #
396       resources {
397         cpu           = 500
398         # The network stanza specifies the networking requirements for the task
399         # group, including the network mode and port allocations. When scheduling
400         # jobs in Nomad they are provisioned across your fleet of machines along
401         # with other jobs and services. Because you don't know in advance what host
402         # your job will be provisioned on, Nomad will provide your tasks with
403         # network configuration when they start up.
404         #
405         #     https://www.nomadproject.io/docs/job-specification/network
406         #
407         network {
408           port "${node_service_name}" {
409             static    = ${node_port}
410           }
411         }
412       }
413     }
414
415     task "prod-task2-${blackbox_service_name}-arm64" {
416       # The "driver" parameter specifies the task driver that should be used to
417       # run the task.
418       driver          = "exec"
419
420       # The "config" stanza specifies the driver configuration, which is passed
421       # directly to the driver to start the task. The details of configurations
422       # are specific to each driver, so please see specific driver
423       # documentation for more information.
424       config {
425         command       = "local/blackbox_exporter-${blackbox_version}.linux-arm64/blackbox_exporter"
426         args          = [
427           "--config.file=secrets/blackbox.yml"
428         ]
429       }
430
431       # The "template" stanza instructs Nomad to manage a template, such as
432       # a configuration file or script. This template can optionally pull data
433       # from Consul or Vault to populate runtime configuration data.
434       #
435       #     https://www.nomadproject.io/docs/job-specification/template
436       #
437       template {
438         change_mode     = "noop"
439         change_signal   = "SIGINT"
440         destination     = "secrets/blackbox.yml"
441         data            = <<EOH
442 modules:
443   http_2xx:
444     prober: http
445     timeout: 5s
446     http:
447       valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
448       no_follow_redirects: false
449       fail_if_ssl: false
450       fail_if_not_ssl: true
451       tls_config:
452         insecure_skip_verify: false
453       preferred_ip_protocol: "ip4"
454   icmp_v4:
455     prober: icmp
456     timeout: 5s
457     icmp:
458       preferred_ip_protocol: "ip4"
459   dns_udp:
460     prober: dns
461     timeout: 5s
462     dns:
463       query_name: "jenkins.fd.io"
464       query_type: "A"
465       valid_rcodes:
466       - NOERROR
467 EOH
468       }
469
470       # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
471       # such as a file, tarball, or binary. Nomad downloads artifacts using the
472       # popular go-getter library, which permits downloading artifacts from a
473       # variety of locations using a URL as the input source.
474       #
475       #     https://www.nomadproject.io/docs/job-specification/artifact
476       #
477       artifact {
478         source        = "${blackbox_url_arm64}"
479       }
480
481       # The service stanza instructs Nomad to register a service with Consul.
482       #
483       #     https://www.nomadproject.io/docs/job-specification/service
484       #
485       service {
486         name          = "${blackbox_service_name}"
487         port          = "${blackbox_service_name}"
488         tags          = [ "${blackbox_service_name}$${NOMAD_ALLOC_INDEX}" ]
489         check {
490           name        = "Blackbox Exporter Check Live"
491           type        = "http"
492           path        = "/metrics"
493           interval    = "10s"
494           timeout     = "2s"
495         }
496       }
497
498       # The "resources" stanza describes the requirements a task needs to
499       # execute. Resource requirements include memory, network, cpu, and more.
500       # This ensures the task will execute on a machine that contains enough
501       # resource capacity.
502       #
503       #     https://www.nomadproject.io/docs/job-specification/resources
504       #
505       resources {
506         cpu           = 500
507         # The network stanza specifies the networking requirements for the task
508         # group, including the network mode and port allocations. When scheduling
509         # jobs in Nomad they are provisioned across your fleet of machines along
510         # with other jobs and services. Because you don't know in advance what host
511         # your job will be provisioned on, Nomad will provide your tasks with
512         # network configuration when they start up.
513         #
514         #     https://www.nomadproject.io/docs/job-specification/network
515         #
516         network {
517           port "${blackbox_service_name}" {
518             static    = ${blackbox_port}
519           }
520         }
521       }
522     }
523
524     task "prod-task3-${cadvisor_service_name}-arm64" {
525       # The "driver" parameter specifies the task driver that should be used to
526       # run the task.
527       driver          = "docker"
528
529       # The "config" stanza specifies the driver configuration, which is passed
530       # directly to the driver to start the task. The details of configurations
531       # are specific to each driver, so please see specific driver
532       # documentation for more information.
533       config {
534         # There is currently no official release for arm yet...using community.
535         image         = "zcube/cadvisor:latest"
536         volumes       = [
537           "/:/rootfs:ro",
538           "/var/run:/var/run:rw",
539           "/sys:/sys:ro",
540           "/var/lib/docker/:/var/lib/docker:ro",
541           "/cgroup:/cgroup:ro"
542         ]
543       }
544
545       # The service stanza instructs Nomad to register a service with Consul.
546       #
547       #     https://www.nomadproject.io/docs/job-specification/service
548       #
549       service {
550         name          = "${cadvisor_service_name}"
551         port          = "${cadvisor_service_name}"
552         check {
553           name        = "cAdvisor Check Live"
554           type        = "http"
555           path        = "/metrics"
556           interval    = "10s"
557           timeout     = "2s"
558         }
559       }
560
561       # The "resources" stanza describes the requirements a task needs to
562       # execute. Resource requirements include memory, network, cpu, and more.
563       # This ensures the task will execute on a machine that contains enough
564       # resource capacity.
565       #
566       #     https://www.nomadproject.io/docs/job-specification/resources
567       #
568       resources {
569         cpu           = 500
570         # The network stanza specifies the networking requirements for the task
571         # group, including the network mode and port allocations. When scheduling
572         # jobs in Nomad they are provisioned across your fleet of machines along
573         # with other jobs and services. Because you don't know in advance what host
574         # your job will be provisioned on, Nomad will provide your tasks with
575         # network configuration when they start up.
576         #
577         #     https://www.nomadproject.io/docs/job-specification/network
578         #
579         network {
580           port "${cadvisor_service_name}" {
581             static    = ${cadvisor_port}
582           }
583         }
584       }
585     }
586   }
587 }