CreateTaskTemplate
Create a task template, including parameters such as Resource, Image, and ENV.
POST
https://api.alayanew.com/api/serverless-train/v1/template
Authorizations
Authorizations:StringHeaderRequired
用户可通过已获取Open API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。
Body
application/json
name:StringRequired
Template name, for example: my-debug.
vksId:StringRequired
Elastic container cluster ID, for example: vc3jedd7crnd.
namespace:StringRequired
The namespace of the elastic container cluster, for example: default.
labels:Object
Labels for task execution.
replicas:IntRequired
Number of task replicas (1-100 for task), default value is 1.
workDir:StringRequired
The working directory of the code, for example: /root/.
cmd:Array[String]Required
Execution commands.
args:Array[String]
Arguments for the execution commands.
env:Object
Environment variables.
resource:ObjectRequired
image:StringRequired
Image name.
imagePullSecret:Object
pvcMounts:Array
extensions:Object
Extension fields.
Response
状态码:application/json
200
code:Int
code is a common return value form, representing the execution result of the query operation.
0
-1
0 is the success identifier, indicating that the operation completed successfully.
data:Object
msg:String
When the code return value is -1, error information is returned.
cURL
Python
JavaScript
Go
Java
curl -X POST 'https://api.alayanew.com/api/serverless-train/v1/template'
-H 'Authorization: plain Credential=YOUR_AK,Signature=YOUR_SK'
-H 'Content-Type: application/json'
-d '{
"name": "my-debug",
"vksId": "vc3jedd7crnd",
"namespace": "default",
"replicas": 1,
"workDir": "/root/",
"cmd": ["bash", "-c", "python3 main.py"],
"resource": {
"cpu": 2,
"mem": 8,
"gpu": {
"count": 1,
"gpuType": "nvidia.com/gpu-tesla-p4"
},
"epheneralStorage": 32
},
"image": "registry.hd-01.alayanew.com/aladdin/python:3.13",
"pvcMounts": [
{
"pvcName": "pvc-capacity-userdata",
"subPath": "a",
"containerPath": "/a",
"readOnly": false
}
],
"imagePullSecret": {
"registry": "https://registry.hd-01.alayanew.com",
"username": "[username]",
"password": "[password]"
},
"extensions": {
"tag": "3",
"tenantId": "dc8e48eb-4c05-4466-8ee2-2c3f969352bf"
}
}'
200
400
401
403
404
500
{
"code": 0,
"data": {
"id": "5df0ef3c-252a-44c8-aba3-a87e23615c76"
}
}