github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/csi_plugin.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: csi_plugin Stanza - Job Specification
     4  sidebar_title: csi_plugin <sup>Beta</sup>
     5  description: >-
     6    The "csi_plugin" stanza allows the task to specify it provides a
     7    Container Storage Interface plugin to the cluster.
     8  ---
     9  
    10  # `csi_plugin` Stanza
    11  
    12  <Placement groups={['job', 'group', 'task', 'volume']} />
    13  
    14  The "csi_plugin" stanza allows the task to specify it provides a
    15  Container Storage Interface plugin to the cluster. Nomad will
    16  automatically register the plugin so that it can be used by other jobs
    17  to claim [volumes][csi_volumes].
    18  
    19  ```hcl
    20  csi_plugin {
    21    id        = "csi-hostpath"
    22    type      = "monolith"
    23    mount_dir = "/csi"
    24  }
    25  ```
    26  
    27  ## `csi_plugin` Parameters
    28  
    29  - `id` `(string: <required>)` - This is the ID for the plugin. Some
    30    plugins will require both controller and node plugin types (see
    31    below); you need to use the same ID for both so that Nomad knows they
    32    belong to the same plugin.
    33  
    34  - `type` `(string: <required>)` - One of `node`, `controller`, or
    35    `monolith`. Each plugin supports one or more types. Each Nomad
    36    client node where you want to mount a volume will need a `node`
    37    plugin instance. Some plugins will also require one or more
    38    `controller` plugin instances to communicate with the storage
    39    provider's APIs. Some plugins can serve as both `controller` and
    40    `node` at the same time, and these are called `monolith`
    41    plugins. Refer to your CSI plugin's documentation.
    42  
    43  - `mount_dir` `(string: <required>)` - The directory path inside the
    44    container where the plugin will expect a Unix domain socket for
    45    bidirectional communication with Nomad.
    46  
    47  ~> **Note:** Plugins running as `node` or `monolith` require root
    48  privileges (or `CAP_SYS_ADMIN` on Linux) to mount volumes on the
    49  host. With the Docker task driver, you can use the `privileged = true`
    50  configuration, but no other default task drivers currently have this
    51  option.
    52  
    53  ~> **Note:** During node drains, jobs that claim volumes must be moved before
    54  the `node` or `monolith` plugin for those volumes. You should run `node` or
    55  `monolith` plugins as [`system`][system] jobs and use the `-ignore-system`
    56  flag on `nomad node drain` to ensure that the plugins are running while the
    57  node is being drained.
    58  
    59  ~> **Note:** Only one plugin instance of a given plugin ID and type
    60  (controller or node) should be deployed on any given client node. Use a
    61  constraint as shown below.
    62  
    63  ## `csi_plugin` Examples
    64  
    65  ```hcl
    66  job "plugin-efs" {
    67    datacenters = ["dc1"]
    68  
    69    # you can run node plugins as service jobs as well, but running
    70    # as a system job ensures all nodes in the DC have a copy.
    71    type = "system"
    72  
    73    # only one plugin of a given type and ID should be deployed on
    74    # any given client node
    75    constraint {
    76      operator = "distinct_hosts"
    77      value = true
    78    }
    79  
    80    group "nodes" {
    81      task "plugin" {
    82        driver = "docker"
    83  
    84        config {
    85          image = "amazon/aws-efs-csi-driver:latest"
    86  
    87          args = [
    88            "node",
    89            "--endpoint=unix://csi/csi.sock",
    90            "--logtostderr",
    91            "--v=5",
    92          ]
    93  
    94          # all CSI node plugins will need to run as privileged tasks
    95          # so they can mount volumes to the host. controller plugins
    96          # do not need to be privileged.
    97          privileged = true
    98        }
    99  
   100        csi_plugin {
   101          id        = "aws-efs0"
   102          type      = "node"
   103          mount_dir = "/csi"  # this path /csi matches the --endpoint
   104                              # argument for the container
   105        }
   106      }
   107    }
   108  }
   109  ```
   110  
   111  [csi]: https://github.com/container-storage-interface/spec
   112  [csi_volumes]: /docs/job-specification/volume
   113  [system]: /docs/schedulers#system