github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/commands/job/plan.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: 'Commands: job plan'
     4  sidebar_title: plan
     5  description: |
     6    The job plan command is used to dry-run a job update to determine its effects.
     7  ---
     8  
     9  # Command: job plan
    10  
    11  **Alias: `nomad plan`**
    12  
    13  The `job plan` command can be used to invoke the scheduler in a dry-run mode
    14  with new jobs or when updating existing jobs to determine what would happen if
    15  the job is submitted. Job files must conform to the [job specification] format.
    16  
    17  ## Usage
    18  
    19  ```plaintext
    20  nomad job plan [options] <path>
    21  ```
    22  
    23  The `job plan` command requires a single argument, specifying the path to a file
    24  containing an HCL [job specification]. This file will be read and the resulting
    25  parsed job will be validated. If the supplied path is "-", the job file is read
    26  from STDIN. Otherwise it is read from the file at the supplied path or
    27  downloaded and read from URL specified. Nomad downloads the job file using
    28  [`go-getter`] and supports `go-getter` syntax.
    29  
    30  Plan invokes a dry-run of the scheduler to determine the effects of submitting
    31  either a new or updated version of a job. The plan will not result in any
    32  changes to the cluster but gives insight into whether the job could be run
    33  successfully and how it would affect existing allocations.
    34  
    35  A job modify index is returned with the plan. This value can be used when
    36  submitting the job using [`nomad job run -check-index`], which will check that
    37  the job was not modified between the plan and run command before invoking the
    38  scheduler. This ensures the job has not been modified since the plan.
    39  
    40  A structured diff between the local and remote job is displayed to
    41  give insight into what the scheduler will attempt to do and why.
    42  
    43  If the job has specified the region, the `-region` flag and `NOMAD_REGION`
    44  environment variable are overridden and the job's region is used.
    45  
    46  Plan will return one of the following exit codes:
    47  
    48  - 0: No allocations created or destroyed.
    49  - 1: Allocations created or destroyed.
    50  - 255: Error determining plan results.
    51  
    52  ## General Options
    53  
    54  @include 'general_options.mdx'
    55  
    56  ## Plan Options
    57  
    58  - `-diff`: Determines whether the diff between the remote job and planned job is
    59    shown. Defaults to true.
    60  
    61  - `-policy-override`: Sets the flag to force override any soft mandatory
    62    Sentinel policies.
    63  
    64  - `-verbose`: Increase diff verbosity.
    65  
    66  ## Examples
    67  
    68  Plan a new job that has not been previously submitted:
    69  
    70  ```shell-sessionnomad job plan job1.nomad
    71  nomad job plan example.nomad
    72  + Job: "example"
    73  + Task Group: "cache" (1 create)
    74    + Task: "redis" (forces create)
    75  
    76  Scheduler dry-run:
    77  - All tasks successfully allocated.
    78  
    79  Job Modify Index: 0
    80  To submit the job with version verification run:
    81  
    82  nomad job run -check-index 0 example.nomad
    83  
    84  When running the job with the check-index flag, the job will only be run if the
    85  job modify index given matches the server-side version. If the index has
    86  changed, another user has modified the job and the plan's results are
    87  potentially invalid.
    88  ```
    89  
    90  Increase the count of an existing without sufficient cluster capacity:
    91  
    92  ```shell-sessionnomad job plan example.nomad
    93  +/- Job: "example"
    94  +/- Task Group: "cache" (7 create, 1 in-place update)
    95    +/- Count: "1" => "8" (forces create)
    96        Task: "redis"
    97  
    98  Scheduler dry-run:
    99  - WARNING: Failed to place all allocations.
   100    Task Group "cache" (failed to place 3 allocations):
   101      * Resources exhausted on 1 nodes
   102      * Dimension "cpu" exhausted on 1 nodes
   103  
   104  Job Modify Index: 15
   105  To submit the job with version verification run:
   106  
   107  nomad job run -check-index 15 example.nomad
   108  
   109  When running the job with the check-index flag, the job will only be run if the
   110  job modify index given matches the server-side version. If the index has
   111  changed, another user has modified the job and the plan's results are
   112  potentially invalid.
   113  ```
   114  
   115  Update an existing job such that it would cause a rolling update:
   116  
   117  ```shell-sessionnomad job plan example.nomad
   118  +/- Job: "example"
   119  +/- Task Group: "cache" (3 create/destroy update)
   120    +/- Task: "redis" (forces create/destroy update)
   121      +/- Config {
   122        +/- image:           "redis:2.8" => "redis:3.2"
   123            port_map[0][db]: "6379"
   124      }
   125  
   126  Scheduler dry-run:
   127  - All tasks successfully allocated.
   128  - Rolling update, next evaluation will be in 10s.
   129  
   130  Job Modify Index: 7
   131  To submit the job with version verification run:
   132  
   133  nomad job run -check-index 7 example.nomad
   134  
   135  When running the job with the check-index flag, the job will only be run if the
   136  job modify index given matches the server-side version. If the index has
   137  changed, another user has modified the job and the plan's results are
   138  potentially invalid.
   139  ```
   140  
   141  Add a task to the task group using verbose mode:
   142  
   143  ```shell-sessionnomad job plan -verbose example.nomad
   144  +/- Job: "example"
   145  +/- Task Group: "cache" (3 create/destroy update)
   146    + Task: "my-website" (forces create/destroy update)
   147      + Driver:      "docker"
   148      + KillTimeout: "5000000000"
   149      + Config {
   150        + image:            "node:6.2"
   151        + port_map[0][web]: "80"
   152      }
   153      + Resources {
   154        + CPU:      "500"
   155        + DiskMB:   "300"
   156        + MemoryMB: "256"
   157        + Network {
   158          + MBits: "10"
   159          + Dynamic Port {
   160            + Label: "web"
   161          }
   162        }
   163      }
   164      + LogConfig {
   165        + MaxFileSizeMB: "10"
   166        + MaxFiles:      "10"
   167      }
   168      + Service {
   169        + Name:      "website"
   170        + PortLabel: "web"
   171        + Check {
   172            Command:  ""
   173          + Interval: "10000000000"
   174          + Name:     "alive"
   175            Path:     ""
   176            Protocol: ""
   177          + Timeout:  "2000000000"
   178          + Type:     "tcp"
   179        }
   180      }
   181      Task: "redis"
   182  
   183  Scheduler dry-run:
   184  - All tasks successfully allocated.
   185  - Rolling update, next evaluation will be in 10s.
   186  
   187  Job Modify Index: 7
   188  To submit the job with version verification run:
   189  
   190  nomad job run -check-index 7 example.nomad
   191  
   192  When running the job with the check-index flag, the job will only be run if the
   193  job modify index given matches the server-side version. If the index has
   194  changed, another user has modified the job and the plan's results are
   195  potentially invalid.
   196  ```
   197  
   198  [job specification]: /docs/job-specification
   199  [hcl job specification]: /docs/job-specification
   200  [`go-getter`]: https://github.com/hashicorp/go-getter
   201  [`nomad job run -check-index`]: /docs/commands/job/run#check-index