Creating a Job
Function
This API is used to create a job.
There are constraints on mounting OBS buckets during job creation. For details, see Constraints on OBS Bucket Mounting.
URI
POST /apis/batch/v1/namespaces/{namespace}/jobs
|
Parameter |
Description |
|---|---|
|
namespace |
Object name and auth scope, such as for teams and projects. |
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
pretty |
No |
If 'true', then the output is pretty printed. |
Request
Request parameters
For the description about request parameters, see Table 97.
Example request
{
"apiVersion": "batch/v1",
"kind": "Job",
"metadata": {
"name": "pi"
},
"spec": {
"template": {
"metadata": {
"name": "pi"
},
"spec": {
"containers": [
{
"name": "pi",
"image": "perl",
"resources": {
"limits": {
"cpu": "500m",
"memory": "1024Mi"
},
"requests": {
"cpu": "500m",
"memory": "1024Mi"
}
},
"command": [
"perl",
"-Mbignum=bpi",
"-wle",
"print bpi(2000)"
]
}
],
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"restartPolicy": "Never",
"priority": 0
}
}
}
}
Response
Response parameters
For the description about response parameters, see Table 97.
Example response
{
"kind": "Job",
"apiVersion": "batch/v1",
"metadata": {
"name": "pi",
"namespace": "namespace-test",
"selfLink": "/apis/batch/v1/namespaces/namespace-test/jobs/pi",
"uid": "8c923079-b0a8-11e8-8bcb-f898ef6c78b4",
"resourceVersion": "5391201",
"creationTimestamp": "2018-09-05T01:10:59Z",
"labels": {
"controller-uid": "8c923079-b0a8-11e8-8bcb-f898ef6c78b4",
"job-name": "pi"
},
"enable": true
},
"spec": {
"parallelism": 1,
"completions": 1,
"backoffLimit": 6,
"selector": {
"matchLabels": {
"controller-uid": "8c923079-b0a8-11e8-8bcb-f898ef6c78b4"
}
},
"template": {
"metadata": {
"name": "pi",
"creationTimestamp": null,
"labels": {
"controller-uid": "8c923079-b0a8-11e8-8bcb-f898ef6c78b4",
"job-name": "pi"
},
"annotations": {
"cri.cci.io/container-type": "secure-container"
},
"enable": true
},
"spec": {
"containers": [
{
"name": "pi",
"image": "perl",
"command": [
"perl",
"-Mbignum=bpi",
"-wle",
"print bpi(2000)"
],
"resources": {
"limits": {
"cpu": "500m",
"memory": "1Gi"
},
"requests": {
"cpu": "500m",
"memory": "1Gi"
}
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Never",
"priority": 0,
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"imagePullSecrets": [
{
"name": "imagepull-secret"
}
],
"schedulerName": "default-scheduler"
}
}
},
"status": {}
}
Status Code
Table 3 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
200 |
The request has been fulfilled, resulting in the creation of a new resource. |
For more status codes, see Status Codes.
Last Article: Job
Next Article: Reading a Job
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.