feat(Terraform): Minio S3 gateway proxy
[csit.git] / fdio.infra.terraform / 1n_nmd / minio_s3_gateway / 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    = "${region}"
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        = "service"
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      = ${max_parallel}
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            = ${canary}
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      = ${auto_promote}
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       = ${auto_revert}
69 %{ endif }
70   }
71
72   # All groups in this job should be scheduled on different hosts.
73   constraint {
74     operator = "distinct_hosts"
75     value    = "true"
76   }
77
78   # The "group" stanza defines a series of tasks that should be co-located on
79   # the same Nomad client. Any task within a group will be placed on the same
80   # client.
81   #
82   #     https://www.nomadproject.io/docs/job-specification/group
83   #
84   group "${job_name}-group-1" {
85     # The "count" parameter specifies the number of the task groups that should
86     # be running under this group. This value must be non-negative and defaults
87     # to 1.
88     count = ${group_count}
89
90     # The volume stanza allows the group to specify that it requires a given
91     # volume from the cluster. The key of the stanza is the name of the volume
92     # as it will be exposed to task configuration.
93     #
94     # https://www.nomadproject.io/docs/job-specification/volume
95     %{ if use_host_volume }
96     volume "${job_name}-volume-1" {
97       type      = "host"
98       read_only = false
99       source    = "${volume_source}"
100     }
101     %{ endif }
102
103     # The restart stanza configures a tasks's behavior on task failure. Restarts
104     # happen on the client that is running the task.
105     #
106     # https://www.nomadproject.io/docs/job-specification/restart
107     #
108     restart {
109       interval = "30m"
110       attempts = 40
111       delay    = "15s"
112       mode     = "delay"
113     }
114
115     # The network stanza specifies the networking requirements for the task
116     # group, including the network mode and port allocations. When scheduling
117     # jobs in Nomad they are provisioned across your fleet of machines along
118     # with other jobs and services. Because you don't know in advance what host
119     # your job will be provisioned on, Nomad will provide your tasks with
120     # network configuration when they start up.
121     #
122     #     https://www.nomadproject.io/docs/job-specification/network
123     #
124     network {
125       port "base" {
126         static = ${port_base}
127         to     = ${port_base}
128       }
129       port "console" {
130         static = ${port_console}
131         to     = ${port_console}
132       }
133     }
134
135     # The "task" stanza creates an individual unit of work, such as a Docker
136     # container, web application, or batch processing.
137     #
138     #     https://www.nomadproject.io/docs/job-specification/task.html
139     #
140     task "${job_name}-task-1" {
141       # The "driver" parameter specifies the task driver that should be used to
142       # run the task.
143       driver = "exec"
144
145     %{ if use_host_volume }
146       volume_mount {
147         volume      = "${job_name}-volume-1"
148         destination = "${volume_destination}"
149         read_only   = false
150       }
151     %{ endif }
152
153     %{ if use_vault_provider }
154       vault {
155         policies = "${vault_kv_policy_name}"
156       }
157     %{ endif }
158
159       # The "config" stanza specifies the driver configuration, which is passed
160       # directly to the driver to start the task. The details of configurations
161       # are specific to each driver, so please see specific driver
162       # documentation for more information.
163       config {
164         args         = [
165           "${mode}", "s3",
166           "-address", ":${port_base}",
167           "-console-address", ":${port_console}"
168         ]
169         command      = "local/minio"
170       }
171
172       # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
173       # such as a file, tarball, or binary. Nomad downloads artifacts using the
174       # popular go-getter library, which permits downloading artifacts from a
175       # variety of locations using a URL as the input source.
176       #
177       # For more information and examples on the "artifact" stanza, please see
178       # the online documentation at:
179       #
180       #     https://www.nomadproject.io/docs/job-specification/artifact
181       #
182       artifact {
183         source      = "https://dl.min.io/server/minio/release/linux-amd64/minio"
184       }
185
186       # The env stanza configures a list of environment variables to populate
187       # the task's environment before starting.
188       env {
189 %{ if use_vault_provider }
190 {{ with secret "${vault_kv_path}" }}
191         MINIO_ROOT_USER     = "{{ .Data.data.${vault_kv_field_access_key} }}"
192         MINIO_ROOT_PASSWORD = "{{ .Data.data.${vault_kv_field_secret_key} }}"
193 {{ end }}
194 %{ else }
195         MINIO_ROOT_USER       = "${access_key}"
196         MINIO_ROOT_PASSWORD   = "${secret_key}"
197         AWS_ACCESS_KEY_ID     = "${access_key}"
198         AWS_SECRET_ACCESS_KEY = "${secret_key}"
199 %{ endif }
200         ${ envs }
201       }
202
203       # The service stanza instructs Nomad to register a service with Consul.
204       #
205       #     https://www.nomadproject.io/docs/job-specification/service
206       #
207       service {
208         name       = "${service_name}"
209         port       = "base"
210         tags       = [ "${service_name}$${NOMAD_ALLOC_INDEX}" ]
211         check {
212           name     = "Min.io Server HTTP Check Live"
213           type     = "http"
214           port     = "base"
215           protocol = "http"
216           method   = "GET"
217           path     = "/minio/health/live"
218           interval = "10s"
219           timeout  = "2s"
220         }
221         check {
222           name     = "Min.io Server HTTP Check Ready"
223           type     = "http"
224           port     = "base"
225           protocol = "http"
226           method   = "GET"
227           path     = "/minio/health/ready"
228           interval = "10s"
229           timeout  = "2s"
230         }
231       }
232
233       # The "resources" stanza describes the requirements a task needs to
234       # execute. Resource requirements include memory, network, cpu, and more.
235       # This ensures the task will execute on a machine that contains enough
236       # resource capacity.
237       #
238       #     https://www.nomadproject.io/docs/job-specification/resources
239       #
240       resources {
241         cpu        = ${cpu}
242         memory     = ${memory}
243       }
244     }
245   }
246 }