a2df44f66608e8b582166101ba40f8c1ea956546
[csit.git] / terraform-ci-infra / 1n_nmd / minio / conf / nomad / minio.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   # For more information, please see the online documentation at:
16   #
17   #     https://www.nomadproject.io/docs/jobspec/schedulers.html
18   #
19   type        = "service"
20
21   update {
22     # The "max_parallel" parameter specifies the maximum number of updates to
23     # perform in parallel. In this case, this specifies to update a single task
24     # at a time.
25     max_parallel      = 1
26
27     health_check      = "checks"
28
29     # The "min_healthy_time" parameter specifies the minimum time the allocation
30     # must be in the healthy state before it is marked as healthy and unblocks
31     # further allocations from being updated.
32     min_healthy_time  = "10s"
33
34     # The "healthy_deadline" parameter specifies the deadline in which the
35     # allocation must be marked as healthy after which the allocation is
36     # automatically transitioned to unhealthy. Transitioning to unhealthy will
37     # fail the deployment and potentially roll back the job if "auto_revert" is
38     # set to true.
39     healthy_deadline  = "3m"
40
41     # The "progress_deadline" parameter specifies the deadline in which an
42     # allocation must be marked as healthy. The deadline begins when the first
43     # allocation for the deployment is created and is reset whenever an allocation
44     # as part of the deployment transitions to a healthy state. If no allocation
45     # transitions to the healthy state before the progress deadline, the
46     # deployment is marked as failed.
47     progress_deadline = "10m"
48
49 %{ if use_canary }
50     # The "canary" parameter specifies that changes to the job that would result
51     # in destructive updates should create the specified number of canaries
52     # without stopping any previous allocations. Once the operator determines the
53     # canaries are healthy, they can be promoted which unblocks a rolling update
54     # of the remaining allocations at a rate of "max_parallel".
55     #
56     # Further, setting "canary" equal to the count of the task group allows
57     # blue/green deployments. When the job is updated, a full set of the new
58     # version is deployed and upon promotion the old version is stopped.
59     canary            = 1
60
61     # Specifies if the job should auto-promote to the canary version when all
62     # canaries become healthy during a deployment. Defaults to false which means
63     # canaries must be manually updated with the nomad deployment promote
64     # command.
65     auto_promote      = true
66
67     # The "auto_revert" parameter specifies if the job should auto-revert to the
68     # last stable job on deployment failure. A job is marked as stable if all the
69     # allocations as part of its deployment were marked healthy.
70     auto_revert       = true
71 %{ endif }
72   }
73
74   # All groups in this job should be scheduled on different hosts.
75   constraint {
76     operator          = "distinct_hosts"
77     value             = "true"
78   }
79
80   # The "group" stanza defines a series of tasks that should be co-located on
81   # the same Nomad client. Any task within a group will be placed on the same
82   # client.
83   #
84   # For more information and examples on the "group" stanza, please see
85   # the online documentation at:
86   #
87   #     https://www.nomadproject.io/docs/job-specification/group.html
88   #
89   group "prod-group1-minio" {
90     # The "count" parameter specifies the number of the task groups that should
91     # be running under this group. This value must be non-negative and defaults
92     # to 1.
93     count       = ${group_count}
94
95     # https://www.nomadproject.io/docs/job-specification/volume
96     %{ if use_host_volume }
97     volume "prod-volume1-minio" {
98       type      = "host"
99       read_only = false
100       source    = "${host_volume}"
101     }
102     %{ endif }
103
104     # The "task" stanza creates an individual unit of work, such as a Docker
105     # container, web application, or batch processing.
106     #
107     # For more information and examples on the "task" stanza, please see
108     # the online documentation at:
109     #
110     #     https://www.nomadproject.io/docs/job-specification/task.html
111     #
112     task "prod-task1-minio" {
113       # The "driver" parameter specifies the task driver that should be used to
114       # run the task.
115       driver             = "docker"
116
117     %{ if use_host_volume }
118       volume_mount {
119         volume           = "prod-volume1-minio"
120         destination      = "${data_dir}"
121         read_only        = false
122       }
123     %{ endif }
124
125     %{ if use_vault_provider }
126       vault {
127         policies         = "${vault_kv_policy_name}"
128       }
129     %{ endif }
130
131       # The "config" stanza specifies the driver configuration, which is passed
132       # directly to the driver to start the task. The details of configurations
133       # are specific to each driver, so please see specific driver
134       # documentation for more information.
135       config {
136         image            = "${image}"
137         dns_servers      = [ "$${attr.unique.network.ip-address}" ]
138         network_mode     = "host"
139         command          = "server"
140         args             = [ "${host}:${port}${data_dir}" ]
141         port_map {
142           http           = ${port}
143         }
144         privileged       = false
145       }
146
147       # The env stanza configures a list of environment variables to populate
148       # the task's environment before starting.
149       env {
150 %{ if use_vault_provider }
151 {{ with secret "${vault_kv_path}" }}
152         MINIO_ACCESS_KEY = "{{ .Data.data.${vault_kv_field_access_key} }}"
153         MINIO_SECRET_KEY = "{{ .Data.data.${vault_kv_field_secret_key} }}"
154 {{ end }}
155 %{ else }
156         MINIO_ACCESS_KEY = "${access_key}"
157         MINIO_SECRET_KEY = "${secret_key}"
158 %{ endif }
159         ${ envs }
160       }
161
162       # The service stanza instructs Nomad to register a service with Consul.
163       #
164       # For more information and examples on the "task" stanza, please see
165       # the online documentation at:
166       #
167       #     https://www.nomadproject.io/docs/job-specification/service.html
168       #
169       service {
170         name       = "${service_name}"
171         port       = "http"
172         tags       = [ "storage$${NOMAD_ALLOC_INDEX}" ]
173         check {
174           name     = "Min.io Server HTTP Check Live"
175           type     = "http"
176           port     = "http"
177           protocol = "http"
178           method   = "GET"
179           path     = "/minio/health/live"
180           interval = "10s"
181           timeout  = "2s"
182         }
183         check {
184           name     = "Min.io Server HTTP Check Ready"
185           type     = "http"
186           port     = "http"
187           protocol = "http"
188           method   = "GET"
189           path     = "/minio/health/ready"
190           interval = "10s"
191           timeout  = "2s"
192         }
193       }
194
195       # The "resources" stanza describes the requirements a task needs to
196       # execute. Resource requirements include memory, network, cpu, and more.
197       # This ensures the task will execute on a machine that contains enough
198       # resource capacity.
199       #
200       # For more information and examples on the "resources" stanza, please see
201       # the online documentation at:
202       #
203       #     https://www.nomadproject.io/docs/job-specification/resources.html
204       #
205       resources {
206         cpu        = ${cpu}
207         memory     = ${memory}
208         # The network stanza specifies the networking requirements for the task
209         # group, including the network mode and port allocations. When scheduling
210         # jobs in Nomad they are provisioned across your fleet of machines along
211         # with other jobs and services. Because you don't know in advance what host
212         # your job will be provisioned on, Nomad will provide your tasks with
213         # network configuration when they start up.
214         #
215         # For more information and examples on the "template" stanza, please see
216         # the online documentation at:
217         #
218         #     https://www.nomadproject.io/docs/job-specification/network.html
219         #
220         network {
221           port "http" {
222             static = ${port}
223           }
224         }
225       }
226     }
227   }
228 }