Skip to main content

CreateTaskTemplate

更新时间:2025-05-07 16:32:25
Create a task template, including parameters such as Resource, Image, and ENV.
POST
https://api.alayanew.com/api/serverless-train/v1/template
Authorizations
AuthorizationsStringHeaderRequired

用户可通过已获取Open API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。

Body
application/json
nameStringRequired

Template name, for example: my-debug.

vksIdStringRequired

Elastic container cluster ID, for example: vc3jedd7crnd.

namespaceStringRequired

The namespace of the elastic container cluster, for example: default.

labelsObject

Labels for task execution.

replicasIntRequired

Number of task replicas (1-100 for task), default value is 1.

workDirStringRequired

The working directory of the code, for example: /root/.

cmdArray[String]Required

Execution commands.

argsArray[String]

Arguments for the execution commands.

envObject

Environment variables.

resourceObjectRequired

imageStringRequired

Image name.

imagePullSecretObject

pvcMountsArray

extensionsObject

Extension fields.

Response
状态码:application/json
codeInt

code is a common return value form, representing the execution result of the query operation.

0 is the success identifier, indicating that the operation completed successfully.
dataObject

msgString

When the code return value is -1, error information is returned.

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"
              }
            }'
{
    "code": 0,
    "data": {
        "id": "5df0ef3c-252a-44c8-aba3-a87e23615c76"
    }
}