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