2019-08-26 11:09:54 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: volume Stanza - Job Specification
|
|
|
|
sidebar_title: volume
|
|
|
|
description: >-
|
|
|
|
The "volume" stanza allows the group to specify that it requires a given
|
2020-03-24 15:09:46 +00:00
|
|
|
volume from the cluster. Nomad will automatically handle ensuring that the
|
|
|
|
volume is available and mounted into the task.
|
2019-08-26 11:09:54 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# `volume` Stanza
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
<Placement groups={['job', 'group', 'volume']} />
|
2019-08-26 11:09:54 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
The `volume` stanza allows the group to specify that it requires a
|
|
|
|
given volume from the cluster.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
The key of the stanza is the name of the volume as it will be exposed
|
|
|
|
to task configuration.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "docs" {
|
|
|
|
group "example" {
|
|
|
|
volume "certs" {
|
2019-09-12 20:13:04 +00:00
|
|
|
type = "host"
|
2019-09-13 02:32:49 +00:00
|
|
|
source = "ca-certificates"
|
2019-08-26 11:09:54 +00:00
|
|
|
read_only = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
The Nomad server will ensure that the allocations are only scheduled
|
|
|
|
on hosts that have a set of volumes that meet the criteria specified
|
|
|
|
in the `volume` stanzas. These may be [host volumes][host_volume]
|
|
|
|
configured on the client, or [CSI volumes][csi_volume] dynamically
|
|
|
|
mounted by [CSI plugins][csi_plugin].
|
2019-08-26 11:09:54 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
The Nomad client will make the volumes available to tasks according to
|
|
|
|
the [volume_mount][volume_mount] stanza in the `task` configuration.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
|
|
|
## `volume` Parameters
|
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
- `type` `(string: "")` - Specifies the type of a given volume. The
|
|
|
|
valid volume types are `"host"` and `"csi"`.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
- `source` `(string: <required>)` - The name of the volume to
|
|
|
|
request. When using `host_volume`'s this should match the published
|
|
|
|
name of the host volume. When using `csi` volumes, this should match
|
2020-04-23 14:38:08 +00:00
|
|
|
the ID of the registered volume.
|
2019-09-13 02:32:49 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
- `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.
|
2019-08-26 11:09:54 +00:00
|
|
|
|
2020-10-08 12:49:43 +00:00
|
|
|
- `mount_options` - Options for mounting CSI volumes that have the
|
|
|
|
`file-system` [attachment mode]. These options override the `mount_options`
|
|
|
|
field from [volume registration]. Consult the documentation for your storage
|
|
|
|
provider and CSI plugin as to whether these options are required or
|
2020-10-08 16:53:24 +00:00
|
|
|
necessary.
|
2020-10-08 12:49:43 +00:00
|
|
|
|
|
|
|
- `fs_type`: file system type (ex. `"ext4"`)
|
|
|
|
- `mount_flags`: the flags passed to `mount` (ex. `"ro,noatime"`)
|
|
|
|
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
[volume_mount]: /docs/job-specification/volume_mount 'Nomad volume_mount Job Specification'
|
2020-09-29 16:48:32 +00:00
|
|
|
[host_volume]: /docs/configuration/client#host_volume-stanza
|
2020-03-24 15:09:46 +00:00
|
|
|
[csi_volume]: /docs/commands/volume/register
|
|
|
|
[csi_plugin]: /docs/job-specification/csi_plugin
|
2020-10-08 12:49:43 +00:00
|
|
|
[csi_volume]: /docs/commands/volume/register
|
|
|
|
[attachment mode]: /docs/commands/volume/register#attachment_mode
|
|
|
|
[volume registration]: /docs/commands/volume/register#mount_options
|