创建任务模板
创建任务模板,包括Codepath、Resource、image、ENV等参数。每个用户最多可以创建20个模板。
POST
https://api.alayanew.com/api/serverless-train/v1/template
Authorizations
Authorizations:StringHeaderRequired
用户可通过已获取Serverless API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。
Body
application/json
name:StringRequired
模板名称,例如:my-debug。
vksId:StringRequired
弹性容器集群ID,例如:vc3jedd7crnd。
namespace:StringRequired
弹性容器集群的命名空间,例如:default。
labels:Object
任务运行的标签。
replicas:IntRequired
任务副本数(debug,run,shell为1,task,group为1-100),默认值 1,例如:1。
workDir:StringRequired
代码的工作目录,例如:/root/。
cmd:Array[String]Required
执行命令。
args:Array[String]
执行命令的参数。
env:Object
资源。
resource:ObjectRequired
image:StringRequired
镜像名称。
imagePullSecret:Object
pvcMounts:Array
extensions:Object
扩展字段。
Response
状态码:application/json
200
code:Int
code是一种常见的返回值形式,表示查询操作的执行结果。
0
-1
0是成功标识,表示操作成功完成。
data:ObjectRequired
msg:String
code返回值为-1时,返回异常信息。
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": "admin",
"password": "[password]"
},
"extensions": {
"tag": "3",
"tenantId": "dc8e48eb-4c05-4466-8ee2-2c3f969352bf"
}
}'
200
400
401
404
429
503
504
{
"code": 0,
"data": {
"id": "5df0ef3c-252a-44c8-aba3-a87e23615c76"
}
}