2019-08-26 11:09:54 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
|
|
|
page_title: "volume Stanza - Job Specification"
|
|
|
|
sidebar_current: "docs-job-specification-volume"
|
|
|
|
description: |-
|
|
|
|
The "volume" stanza allows the group to specify that it requires a given volume
|
|
|
|
from the cluster. Nomad will automatically handle ensuring that the volume is
|
2019-08-28 18:09:42 +00:00
|
|
|
available and mounted into the task.
|
2019-08-26 11:09:54 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# `volume` Stanza
|
|
|
|
|
|
|
|
<table class="table table-bordered table-striped">
|
|
|
|
<tr>
|
|
|
|
<th width="120">Placement</th>
|
|
|
|
<td>
|
|
|
|
<code>job -> group -> **volume**</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2019-09-12 20:13:04 +00:00
|
|
|
The `volume` stanza allows the group to specify that it requires a given volume
|
2019-09-04 15:42:19 +00:00
|
|
|
from the cluster.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
|
|
|
The key of the stanza is the name of the volume as it will be exposed to task
|
|
|
|
configuration.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "docs" {
|
|
|
|
group "example" {
|
|
|
|
volume "certs" {
|
2019-09-12 20:13:04 +00:00
|
|
|
type = "host"
|
2019-08-26 11:09:54 +00:00
|
|
|
read_only = true
|
|
|
|
|
|
|
|
config {
|
|
|
|
source = "ca-certificates"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
The Nomad server will ensure that the allocations are only scheduled on hosts
|
2019-09-12 20:13:04 +00:00
|
|
|
that have a set of volumes that meet the criteria specified in the `volume`
|
2019-08-28 18:09:42 +00:00
|
|
|
stanzas.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
|
|
|
The Nomad client will make the volumes available to tasks according to the
|
|
|
|
[volume_mount][volume_mount] stanza in the `task` configuration.
|
|
|
|
|
|
|
|
## `volume` Parameters
|
|
|
|
|
|
|
|
- `type` `(string: "")` - Specifies the type of a given volume. Currently the
|
|
|
|
only possible volume type is `"host"`.
|
|
|
|
|
|
|
|
- `read_only` `(bool: false)` - Specifies that the group only requires read only
|
|
|
|
access to a volume and is used as the default value for the `volume_mount ->
|
|
|
|
read_only` configuration. This value is also used for validating `host_volume`
|
|
|
|
ACLs and for scheduling when a matching `host_volume` requires `read_only`
|
|
|
|
usage.
|
|
|
|
|
|
|
|
- `config` `(json/hcl: nil)` - Specifies the configuration for the volume
|
2019-08-28 18:09:42 +00:00
|
|
|
provider. For a `host_volume`, the only key is `source`, which is the name of
|
2019-08-26 11:09:54 +00:00
|
|
|
the volume to request.
|
|
|
|
|
|
|
|
[volume_mount]: /docs/job-specification/volume_mount.html "Nomad volume_mount Job Specification"
|