Creating a Volcano Job
Function
This API is used to create a Volcano job.
URI
POST /apis/batch.volcano.sh/v1alpha1/namespaces/{namespace}/jobs
| Parameter | Mandatory | Description |
|---|---|---|
| namespace | Yes | 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
For the description about request parameters, see Table 145.
Example request
{
"apiVersion": "batch.volcano.sh/v1alpha1",
"kind": "Job",
"metadata": {
"name": "openmpi-hello-2-com"
},
"spec": {
"minAvailable": 1,
"schedulerName": "volcano",
"plugins": {
"ssh": [],
"env": [],
"svc": []
},
"tasks": [
{
"replicas": 1,
"name": "mpimaster",
"policies": [
{
"event": "TaskCompleted",
"action": "CompleteJob"
}
],
"template": {
"spec": {
"imagePullSecrets": [
{
"name": "default-secret"
}
],
"containers": [
{
"command": [
"/bin/sh",
"-c",
"MPI_HOST=`cat/etc/volcano/mpiworker.host|tr\"\\n\"\",\"`;\nmkdir-p/var/run/sshd;/usr/sbin/sshd;\nmpiexec--allow-run-as-root--host${\t\t\t\t\t\t\tMPI_HOST\t\t\t\t\t\t}-np2mpi_hello_world>/home/re\n"
],
"image": "*.*.*.*: 20202/swr/openmpi-hello:3.28",
"name": "mpimaster",
"ports": [
{
"containerPort": 22,
"name": "mpijob-port"
}
],
"resources": {
"requests": {
"cpu": "250m",
"memory": "1Gi"
},
"limits": {
"cpu": "250m",
"memory": "1Gi"
}
},
"workingDir": "/home"
}
],
"restartPolicy": "OnFailure"
}
}
},
{
"replicas": 2,
"name": "mpiworker",
"template": {
"spec": {
"imagePullSecrets": [
{
"name": "default-secret"
}
],
"containers": [
{
"command": [
"/bin/sh",
"-c",
"mkdir-p/var/run/sshd;/usr/sbin/sshd-D;\n"
],
"image": "*.*.*.*:20202/swr/openmpi-hello:3.28",
"name": "mpiworker",
"ports": [
{
"containerPort": 22,
"name": "mpijob-port"
}
],
"workingDir": "/home",
"resources": {
"requests": {
"cpu": "250m",
"memory": "1Gi"
},
"limits": {
"cpu": "250m",
"memory": "1Gi"
}
}
}
],
"restartPolicy": "OnFailure"
}
}
}
]
}
} Response
Response parameters:
For the description about response parameters, see Table 145.
Example response
{
"apiVersion": "batch.volcano.sh/v1alpha1",
"kind": "Job",
"metadata": {
"creationTimestamp": "2019-06-26T06:24:50Z",
"generation": 1,
"name": "openmpi-hello-3-com",
"namespace": "cci-namespace-42263891",
"resourceVersion": "7681331",
"selfLink": "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs/openmpi-hello-3-com",
"uid": "1a32a8c4-97db-11e9-9d09-dc9914fb58e0"
},
"spec": {
"minAvailable": 1,
"plugins": {
"env": [],
"ssh": [],
"svc": []
},
"queue": "default",
"schedulerName": "volcano",
"tasks": [
{
"name": "mpimaster",
"policies": [
{
"action": "CompleteJob",
"event": "TaskCompleted"
}
],
"replicas": 1,
"template": {
"spec": {
"containers": [
{
"command": [
"/bin/sh",
"-c",
"MPI_HOST=`cat /etc/volcano/mpiworker.host | tr \"\\n\" \",\"`;\nmkdir -p /var/run/sshd; /usr/sbin/sshd;\nmpiexec --allow-run-as-root --host ${MPI_HOST} -np 2 mpi_hello_world 003e /home/re\n"
],
"image": "*.*.*.*:20202/swr/openmpi-hello:3.28",
"name": "mpimaster",
"ports": [
{
"containerPort": 22,
"name": "mpijob-port"
}
],
"resources": {
"limits": {
"cpu": "250m",
"memory": "1Gi"
},
"requests": {
"cpu": "250m",
"memory": "1Gi"
}
},
"workingDir": "/home"
}
],
"imagePullSecrets": [
{
"name": "default-secret"
}
],
"restartPolicy": "OnFailure"
}
}
},
{
"name": "mpiworker",
"replicas": 2,
"template": {
"spec": {
"containers": [
{
"command": [
"/bin/sh",
"-c",
"mkdir -p /var/run/sshd; /usr/sbin/sshd -D;\n"
],
"image": "*.*.*.*:20202/swr/openmpi-hello:3.28",
"name": "mpiworker",
"ports": [
{
"containerPort": 22,
"name": "mpijob-port"
}
],
"resources": {
"limits": {
"cpu": "250m",
"memory": "1Gi"
},
"requests": {
"cpu": "250m",
"memory": "1Gi"
}
},
"workingDir": "/home"
}
],
"imagePullSecrets": [
{
"name": "default-secret"
}
],
"restartPolicy": "OnFailure"
}
}
}
]
}
} Status Code
| Status Code | Description |
|---|---|
| 200 | OK |
| 201 | Created |
| 202 | Accepted |
| 401 | Unauthorized |
| 400 | Badrequest |
| 500 | Internal error |
| 403 | Forbidden |
Last Article: Reading All Volcano Jobs Under a Namespace
Next Article: Deleting All Volcano Jobs Under a Namespace
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.