2020-03-24 15:09:46 +00:00
|
|
|
---
|
|
|
|
layout: docs
|
2023-01-30 14:48:43 +00:00
|
|
|
page_title: csi_plugin Block - Job Specification
|
2020-03-24 15:09:46 +00:00
|
|
|
description: >-
|
2023-01-30 14:48:43 +00:00
|
|
|
The "csi_plugin" block allows the task to specify it provides a
|
2020-03-24 15:09:46 +00:00
|
|
|
Container Storage Interface plugin to the cluster.
|
|
|
|
---
|
|
|
|
|
2023-01-30 14:48:43 +00:00
|
|
|
# `csi_plugin` Block
|
2020-03-24 15:09:46 +00:00
|
|
|
|
2022-07-25 14:06:59 +00:00
|
|
|
<Placement groups={['job', 'group', 'task', 'csi_plugin']} />
|
2020-03-24 15:09:46 +00:00
|
|
|
|
2023-01-30 14:48:43 +00:00
|
|
|
The "csi_plugin" block allows the task to specify it provides a
|
2020-03-24 15:09:46 +00:00
|
|
|
Container Storage Interface plugin to the cluster. Nomad will
|
|
|
|
automatically register the plugin so that it can be used by other jobs
|
|
|
|
to claim [volumes][csi_volumes].
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
csi_plugin {
|
2022-08-02 13:42:44 +00:00
|
|
|
id = "csi-hostpath"
|
|
|
|
type = "monolith"
|
|
|
|
mount_dir = "/csi"
|
|
|
|
stage_publish__base_dir = "/local/csi"
|
|
|
|
health_timeout = "30s"
|
2020-03-24 15:09:46 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## `csi_plugin` Parameters
|
|
|
|
|
|
|
|
- `id` `(string: <required>)` - This is the ID for the plugin. Some
|
|
|
|
plugins will require both controller and node plugin types (see
|
2020-11-27 06:56:13 +00:00
|
|
|
below); you need to use the same ID for both so that Nomad knows they
|
2020-03-24 15:09:46 +00:00
|
|
|
belong to the same plugin.
|
|
|
|
|
|
|
|
- `type` `(string: <required>)` - One of `node`, `controller`, or
|
|
|
|
`monolith`. Each plugin supports one or more types. Each Nomad
|
|
|
|
client node where you want to mount a volume will need a `node`
|
|
|
|
plugin instance. Some plugins will also require one or more
|
|
|
|
`controller` plugin instances to communicate with the storage
|
|
|
|
provider's APIs. Some plugins can serve as both `controller` and
|
|
|
|
`node` at the same time, and these are called `monolith`
|
|
|
|
plugins. Refer to your CSI plugin's documentation.
|
|
|
|
|
2022-08-02 13:42:44 +00:00
|
|
|
- `mount_dir` `(string: <optional>)` - The directory path inside the
|
2020-03-24 15:09:46 +00:00
|
|
|
container where the plugin will expect a Unix domain socket for
|
2022-08-02 13:42:44 +00:00
|
|
|
bidirectional communication with Nomad. This field is typically not
|
|
|
|
required. Refer to your CSI plugin's documentation for details.
|
|
|
|
|
2023-01-30 14:48:43 +00:00
|
|
|
- `stage_publish_base_dir` `(string: <optional>)` - The base directory
|
2022-08-02 13:42:44 +00:00
|
|
|
path inside the container where the plugin will be instructed to
|
2023-01-30 14:48:43 +00:00
|
|
|
stage and publish volumes. This field is typically not required.
|
2022-08-02 13:42:44 +00:00
|
|
|
Refer to your CSI plugin's documentation for details.
|
2020-03-24 15:09:46 +00:00
|
|
|
|
2023-01-30 14:48:43 +00:00
|
|
|
- `health_timeout` `(duration: <optional>)` - The duration that
|
2022-06-14 14:04:16 +00:00
|
|
|
the plugin supervisor will wait before restarting an unhealthy
|
|
|
|
CSI plugin. Must be a duration value such as `30s` or `2m`.
|
2023-01-30 14:48:43 +00:00
|
|
|
Defaults to `30s` if not set.
|
2022-06-14 14:04:16 +00:00
|
|
|
|
2020-04-07 11:51:50 +00:00
|
|
|
~> **Note:** Plugins running as `node` or `monolith` require root
|
|
|
|
privileges (or `CAP_SYS_ADMIN` on Linux) to mount volumes on the
|
|
|
|
host. With the Docker task driver, you can use the `privileged = true`
|
|
|
|
configuration, but no other default task drivers currently have this
|
|
|
|
option.
|
|
|
|
|
2021-06-22 14:23:09 +00:00
|
|
|
## Recommendations for Deploying CSI Plugins
|
|
|
|
|
2022-04-05 21:13:51 +00:00
|
|
|
CSI plugins run as Nomad tasks, but after mounting the volume are not in the
|
|
|
|
data path for the volume. Tasks that mount volumes write and read directly to
|
2021-06-22 14:23:09 +00:00
|
|
|
the volume via a bind-mount and there is no communication between the job and
|
|
|
|
the CSI plugin. But when an allocation that mounts a volume stops, Nomad will
|
|
|
|
need to communicate with the plugin on that allocation's node to unmount the
|
|
|
|
volume. This has implications on how to deploy CSI plugins:
|
|
|
|
|
2022-04-05 21:13:51 +00:00
|
|
|
* If you are stopping jobs on a node, you must stop tasks that claim
|
|
|
|
volumes before stopping the `node` or `monolith` plugin for those
|
|
|
|
volumes. If you use the `node drain` feature, plugin tasks will
|
|
|
|
automatically be drained last.
|
2021-06-22 14:23:09 +00:00
|
|
|
|
2022-04-05 21:13:51 +00:00
|
|
|
* Only the most recently-placed allocation for a given plugin ID and
|
|
|
|
type (controller or node) will be used by any given client node. Run
|
|
|
|
`node` plugins as system jobs and distribute `controller` plugins
|
|
|
|
across client nodes using a constraint as shown below.
|
2021-06-22 14:23:09 +00:00
|
|
|
|
|
|
|
* Some plugins will create volumes only in the same location as the
|
2022-04-05 21:13:51 +00:00
|
|
|
plugin. For example, the AWS EBS plugin will create and mount
|
|
|
|
volumes only within the same Availability Zone. You should configure
|
|
|
|
your plugin task as recommended by the plugin's documentation to use
|
|
|
|
the [`topology_request`] field in your volume specification.
|
2020-10-08 20:55:55 +00:00
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
## `csi_plugin` Examples
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "plugin-efs" {
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
|
|
|
|
# you can run node plugins as service jobs as well, but running
|
|
|
|
# as a system job ensures all nodes in the DC have a copy.
|
|
|
|
type = "system"
|
|
|
|
|
2020-10-08 20:55:55 +00:00
|
|
|
# only one plugin of a given type and ID should be deployed on
|
|
|
|
# any given client node
|
|
|
|
constraint {
|
|
|
|
operator = "distinct_hosts"
|
|
|
|
value = true
|
|
|
|
}
|
|
|
|
|
2020-03-24 15:09:46 +00:00
|
|
|
group "nodes" {
|
|
|
|
task "plugin" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
2021-06-28 12:28:03 +00:00
|
|
|
image = "amazon/aws-efs-csi-driver:v.1.3.2"
|
2020-03-24 15:09:46 +00:00
|
|
|
|
|
|
|
args = [
|
|
|
|
"--endpoint=unix://csi/csi.sock",
|
|
|
|
"--logtostderr",
|
|
|
|
"--v=5",
|
|
|
|
]
|
|
|
|
|
|
|
|
# all CSI node plugins will need to run as privileged tasks
|
|
|
|
# so they can mount volumes to the host. controller plugins
|
|
|
|
# do not need to be privileged.
|
|
|
|
privileged = true
|
|
|
|
}
|
|
|
|
|
|
|
|
csi_plugin {
|
2022-06-14 14:04:16 +00:00
|
|
|
id = "aws-efs0"
|
|
|
|
type = "node"
|
|
|
|
mount_dir = "/csi" # this path /csi matches the --endpoint
|
2020-03-24 15:09:46 +00:00
|
|
|
# argument for the container
|
2022-06-14 14:04:16 +00:00
|
|
|
health_timeout = "30s"
|
2020-03-24 15:09:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
[csi]: https://github.com/container-storage-interface/spec
|
2023-01-25 17:31:14 +00:00
|
|
|
[csi_volumes]: /nomad/docs/job-specification/volume
|
|
|
|
[system]: /nomad/docs/schedulers#system
|
|
|
|
[`topology_request`]: /nomad/docs/commands/volume/create#topology_request
|