Example JSON is submitable

This PR makes the example JSON job submitable via the HTTP API.
This commit is contained in:
Alex Dadgar
2017-07-28 09:02:15 -07:00
parent 67705efb8f
commit c94aa29ddc

View File

@@ -18,177 +18,104 @@ $ nomad run -output my-job.nomad
## Syntax
Below is an example of a JSON object that submits a `periodic` job to Nomad:
Below is the JSON representation of the job outputed by `$ nomad init`:
```json
{
"Job": {
"Region": "global",
"ID": "example",
"Name": "example",
"Type": "batch",
"Priority": 50,
"AllAtOnce": false,
"Datacenters": [
"dc1"
],
"Constraints": [
{
"LTarget": "${attr.kernel.name}",
"RTarget": "linux",
"Operand": "="
}
],
"TaskGroups": [
{
"Name": "cache",
"Count": 1,
"Constraints": null,
"Tasks": [
{
"Name": "redis",
"Driver": "docker",
"User": "foo-user",
"Config": {
"image": "redis:latest",
"port_map": [
{
"db": 6379
}
]
},
"Constraints": null,
"Env": {
"foo": "bar",
"baz": "pipe"
},
"Services": [
{
"Name": "cache-redis",
"Tags": [
"global",
"cache"
],
"PortLabel": "db",
"Checks": [
{
"Id": "",
"Name": "alive",
"Type": "tcp",
"Command": "",
"Args": null,
"Path": "",
"Protocol": "",
"Interval": 10000000000,
"Timeout": 2000000000
}
]
}
],
"Update": {
"Stagger": 10000000000,
"MaxParallel": 3,
"HealthCheck": "checks",
"MinHealthyTime": 15000000000,
"HealthyDeadline": 180000000000,
"AutoRevert": false,
"Canary": 1
},
"Vault": {
"Policies": [
"policy-name"
],
"Env": true,
"ChangeMode": "restart",
"ChangeSignal": ""
},
"Resources": {
"CPU": 500,
"MemoryMB": 256,
"IOPS": 0,
"Networks": [
{
"ReservedPorts": [
{
"Label": "rpc",
"Value": 25566
}
],
"DynamicPorts": [
{
"Label": "db"
}
],
"MBits": 10
}
]
},
"Meta": {
"foo": "bar",
"baz": "pipe"
},
"KillTimeout": 5000000000,
"LogConfig": {
"MaxFiles": 10,
"MaxFileSizeMB": 10
},
"Templates": [
{
"SourcePath": "local/config.conf.tpl",
"DestPath": "local/config.conf",
"EmbeddedTmpl": "",
"ChangeMode": "signal",
"ChangeSignal": "SIGUSR1",
"Splay": 5000000000
}
],
"Artifacts": [
{
"GetterSource": "http://foo.com/artifact.tar.gz",
"GetterOptions": {
"checksum": "md5:c4aa853ad2215426eb7d70a21922e794"
},
"RelativeDest": "local/"
}
],
"DispatchPayload": {
"File": "config.json"
}
}
"Job": {
"ID": "example",
"Name": "example",
"Type": "service",
"Priority": 50,
"Datacenters": [
"dc1"
],
"RestartPolicy": {
"Interval": 300000000000,
"Attempts": 10,
"Delay": 25000000000,
"Mode": "delay"
},
"Meta": {
"foo": "bar",
"baz": "pipe"
"TaskGroups": [{
"Name": "cache",
"Count": 1,
"Tasks": [{
"Name": "redis",
"Driver": "docker",
"User": "",
"Config": {
"image": "redis:3.2",
"port_map": [{
"db": 6379
}]
},
"Services": [{
"Id": "",
"Name": "global-redis-check",
"Tags": [
"global",
"cache"
],
"PortLabel": "db",
"AddressMode": "",
"Checks": [{
"Id": "",
"Name": "alive",
"Type": "tcp",
"Command": "",
"Args": null,
"Path": "",
"Protocol": "",
"PortLabel": "",
"Interval": 10000000000,
"Timeout": 2000000000,
"InitialStatus": "",
"TLSSkipVerify": false
}]
}],
"Resources": {
"CPU": 500,
"MemoryMB": 256,
"Networks": [{
"Device": "",
"CIDR": "",
"IP": "",
"MBits": 10,
"DynamicPorts": [{
"Label": "db",
"Value": 0
}]
}]
},
"Leader": false
}],
"RestartPolicy": {
"Interval": 300000000000,
"Attempts": 10,
"Delay": 25000000000,
"Mode": "delay"
},
"EphemeralDisk": {
"SizeMB": 300
}
}],
"Update": {
"MaxParallel": 1,
"MinHealthyTime": 10000000000,
"HealthyDeadline": 180000000000,
"AutoRevert": false,
"Canary": 0
}
}
],
"Periodic": {
"Enabled": true,
"Spec": "- *",
"SpecType": "cron",
"ProhibitOverlap": true
},
"Meta": {
"foo": "bar",
"baz": "pipe"
},
"ParameterizedJob": {
"Payload": "required",
"MetaRequired": [
"foo"
],
"MetaOptional": [
"bar"
]
},
"Payload": null
}
}
}
```
The example JSON could be submitted as a job using the following:
```text
$ curl -XPUT @d example.json http://127.0.0.1:4646/v1/job/example
{
"EvalID": "5d6ded54-0b2a-8858-6583-be5f476dec9d",
"EvalCreateIndex": 12,
"JobModifyIndex": 11,
"Warnings": "",
"Index": 12,
"LastContact": 0,
"KnownLeader": false
}
```