github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/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 When ACLs are enabled, this command requires a token with the `submit-job` 53 capability for the job's namespace. 54 55 ## General Options 56 57 @include 'general_options.mdx' 58 59 ## Plan Options 60 61 - `-diff`: Determines whether the diff between the remote job and planned job is 62 shown. Defaults to true. 63 64 - `-policy-override`: Sets the flag to force override any soft mandatory 65 Sentinel policies. 66 67 - `-hcl1`: If set, HCL1 parser is used for parsing the job spec. 68 69 - `-verbose`: Increase diff verbosity. 70 71 ## Examples 72 73 Plan a new job that has not been previously submitted: 74 75 ```shell-session 76 $ nomad job plan job1.nomad 77 nomad job plan example.nomad 78 + Job: "example" 79 + Task Group: "cache" (1 create) 80 + Task: "redis" (forces create) 81 82 Scheduler dry-run: 83 - All tasks successfully allocated. 84 85 Job Modify Index: 0 86 To submit the job with version verification run: 87 88 nomad job run -check-index 0 example.nomad 89 90 When running the job with the check-index flag, the job will only be run if the 91 job modify index given matches the server-side version. If the index has 92 changed, another user has modified the job and the plan's results are 93 potentially invalid. 94 ``` 95 96 Increase the count of an existing without sufficient cluster capacity: 97 98 ```shell-session 99 $ nomad job plan example.nomad 100 +/- Job: "example" 101 +/- Task Group: "cache" (7 create, 1 in-place update) 102 +/- Count: "1" => "8" (forces create) 103 Task: "redis" 104 105 Scheduler dry-run: 106 - WARNING: Failed to place all allocations. 107 Task Group "cache" (failed to place 3 allocations): 108 * Resources exhausted on 1 nodes 109 * Dimension "cpu" exhausted on 1 nodes 110 111 Job Modify Index: 15 112 To submit the job with version verification run: 113 114 nomad job run -check-index 15 example.nomad 115 116 When running the job with the check-index flag, the job will only be run if the 117 job modify index given matches the server-side version. If the index has 118 changed, another user has modified the job and the plan's results are 119 potentially invalid. 120 ``` 121 122 Update an existing job such that it would cause a rolling update: 123 124 ```shell-session 125 $ nomad job plan example.nomad 126 +/- Job: "example" 127 +/- Task Group: "cache" (3 create/destroy update) 128 +/- Task: "redis" (forces create/destroy update) 129 +/- Config { 130 +/- image: "redis:2.8" => "redis:3.2" 131 port_map[0][db]: "6379" 132 } 133 134 Scheduler dry-run: 135 - All tasks successfully allocated. 136 - Rolling update, next evaluation will be in 10s. 137 138 Job Modify Index: 7 139 To submit the job with version verification run: 140 141 nomad job run -check-index 7 example.nomad 142 143 When running the job with the check-index flag, the job will only be run if the 144 job modify index given matches the server-side version. If the index has 145 changed, another user has modified the job and the plan's results are 146 potentially invalid. 147 ``` 148 149 Add a task to the task group using verbose mode: 150 151 ```shell-session 152 $ nomad job plan -verbose example.nomad 153 +/- Job: "example" 154 +/- Task Group: "cache" (3 create/destroy update) 155 + Task: "my-website" (forces create/destroy update) 156 + Driver: "docker" 157 + KillTimeout: "5000000000" 158 + Config { 159 + image: "node:6.2" 160 + port_map[0][web]: "80" 161 } 162 + Resources { 163 + CPU: "500" 164 + DiskMB: "300" 165 + MemoryMB: "256" 166 + Network { 167 + MBits: "10" 168 + Dynamic Port { 169 + Label: "web" 170 } 171 } 172 } 173 + LogConfig { 174 + MaxFileSizeMB: "10" 175 + MaxFiles: "10" 176 } 177 + Service { 178 + Name: "website" 179 + PortLabel: "web" 180 + Check { 181 Command: "" 182 + Interval: "10000000000" 183 + Name: "alive" 184 Path: "" 185 Protocol: "" 186 + Timeout: "2000000000" 187 + Type: "tcp" 188 } 189 } 190 Task: "redis" 191 192 Scheduler dry-run: 193 - All tasks successfully allocated. 194 - Rolling update, next evaluation will be in 10s. 195 196 Job Modify Index: 7 197 To submit the job with version verification run: 198 199 nomad job run -check-index 7 example.nomad 200 201 When running the job with the check-index flag, the job will only be run if the 202 job modify index given matches the server-side version. If the index has 203 changed, another user has modified the job and the plan's results are 204 potentially invalid. 205 ``` 206 207 [job specification]: /docs/job-specification 208 [hcl job specification]: /docs/job-specification 209 [`go-getter`]: https://github.com/hashicorp/go-getter 210 [`nomad job run -check-index`]: /docs/commands/job/run#check-index