github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/website/source/docs/job-specification/group.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "group Stanza - Job Specification"
     4  sidebar_current: "docs-job-specification-group"
     5  description: |-
     6    The "group" stanza defines a series of tasks that should be co-located on the
     7    same Nomad client. Any task within a group will be placed on the same client.
     8  ---
     9  
    10  # `group` Stanza
    11  
    12  <table class="table table-bordered table-striped">
    13    <tr>
    14      <th width="120">Placement</th>
    15      <td>
    16        <code>job -> **group**</code>
    17      </td>
    18    </tr>
    19  </table>
    20  
    21  The `group` stanza defines a series of tasks that should be co-located on the
    22  same Nomad client. Any [task][] within a group will be placed on the same
    23  client.
    24  
    25  ```hcl
    26  job "docs" {
    27    group "example" {
    28      # ...
    29    }
    30  }
    31  ```
    32  
    33  ## `group` Parameters
    34  
    35  - `constraint` <code>([Constraint][]: nil)</code> -
    36    This can be provided multiple times to define additional constraints.
    37  
    38  - `affinity` <code>([Affinity][]: nil)</code> - This can be provided
    39      multiple times to define preferred placement criteria.
    40  
    41  - `spread` <code>([Spread][spread]: nil)</code> - This can be provided
    42    multiple times to define criteria for spreading allocations across a
    43    node attribute or metadata. See the
    44    [Nomad spread reference](/docs/job-specification/spread.html) for more details.
    45  
    46  - `count` `(int: 1)` - Specifies the number of the task groups that should
    47    be running under this group. This value must be non-negative.
    48  
    49  - `ephemeral_disk` <code>([EphemeralDisk][]: nil)</code> - Specifies the
    50    ephemeral disk requirements of the group. Ephemeral disks can be marked as
    51    sticky and support live data migrations.
    52  
    53  - `meta` <code>([Meta][]: nil)</code> - Specifies a key-value map that annotates
    54    with user-defined metadata.
    55  
    56  - `migrate` <code>([Migrate][]: nil)</code> - Specifies the group strategy for
    57    migrating off of draining nodes. Only service jobs with a count greater than
    58    1 support migrate stanzas.
    59  
    60  - `reschedule` <code>([Reschedule][]: nil)</code> - Allows to specify a
    61    rescheduling strategy. Nomad will then attempt to schedule the task on another
    62    node if any of the group allocation statuses become "failed".
    63  
    64  - `restart` <code>([Restart][]: nil)</code> - Specifies the restart policy for
    65    all tasks in this group. If omitted, a default policy exists for each job
    66    type, which can be found in the [restart stanza documentation][restart].
    67  
    68  - `task` <code>([Task][]: <required>)</code> - Specifies one or more tasks to run
    69    within this group. This can be specified multiple times, to add a task as part
    70    of the group.
    71  
    72  - `vault` <code>([Vault][]: nil)</code> - Specifies the set of Vault policies
    73    required by all tasks in this group. Overrides a `vault` block set at the
    74    `job` level.
    75  
    76  ## `group` Examples
    77  
    78  The following examples only show the `group` stanzas. Remember that the
    79  `group` stanza is only valid in the placements listed above.
    80  
    81  ### Specifying Count
    82  
    83  This example specifies that 5 instances of the tasks within this group should be
    84  running:
    85  
    86  ```hcl
    87  group "example" {
    88    count = 5
    89  }
    90  ```
    91  
    92  ### Tasks with Constraint
    93  
    94  This example shows two abbreviated tasks with a constraint on the group. This
    95  will restrict the tasks to 64-bit operating systems.
    96  
    97  ```hcl
    98  group "example" {
    99    constraint {
   100      attribute = "${attr.cpu.arch}"
   101      value     = "amd64"
   102    }
   103  
   104    task "cache" {
   105      # ...
   106    }
   107  
   108    task "server" {
   109      # ...
   110    }
   111  }
   112  ```
   113  
   114  ### Metadata
   115  
   116  This example show arbitrary user-defined metadata on the group:
   117  
   118  ```hcl
   119  group "example" {
   120    meta {
   121      "my-key" = "my-value"
   122    }
   123  }
   124  ```
   125  
   126  [task]: /docs/job-specification/task.html "Nomad task Job Specification"
   127  [job]: /docs/job-specification/job.html "Nomad job Job Specification"
   128  [constraint]: /docs/job-specification/constraint.html "Nomad constraint Job Specification"
   129  [spread]: /docs/job-specification/spread.html "Nomad spread Job Specification"
   130  [affinity]: /docs/job-specification/affinity.html "Nomad affinity Job Specification"
   131  [ephemeraldisk]: /docs/job-specification/ephemeral_disk.html "Nomad ephemeral_disk Job Specification"
   132  [meta]: /docs/job-specification/meta.html "Nomad meta Job Specification"
   133  [migrate]: /docs/job-specification/migrate.html "Nomad migrate Job Specification"
   134  [reschedule]: /docs/job-specification/reschedule.html "Nomad reschedule Job Specification"
   135  [restart]: /docs/job-specification/restart.html "Nomad restart Job Specification"
   136  [vault]: /docs/job-specification/vault.html "Nomad vault Job Specification"