创建集群

更新时间:
复制为 MD 格式

创建一个 BatchCompute 集群。

请求语法

请求行:

POST /clusters?IdempotentToken=vU7xaM9YCqqAFHAVvRVynoMBZSgD0MPn HTTP/1.1

请求方法为 POST ,请求资源为 clusters ,参数说明如下:

属性名称

类型

是否必须

描述

IdempotentToken

string

用于保证请求的幂等性。由用户生成该参数值,要保证在不同请求间唯一,最大不超过64个字符,字符包括了字母、数字以及下划线。

请求数据:

请求数据以 JSON 格式描述:

{
    "Name": "test-cluster",
    "Description": "demo",
    "InstanceType": "ecs.sn1ne.large",
    "ImageId": "img-ubuntu",
    "Bootstrap": "",
    "UserData": {
        "key2": "value2",
        "key1": "value1"
    },
    "EnvVars": {
        "key3": "value3",
        "key4": "value4"
    },
    "Notification": {
        "Topic": {
            "Name": "test-topic",
            "Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
            "Events": [
                "OnClusterDeleted",
                "OnInstanceCreated",
                "OnInstanceActive"
            ]
        }
    },
    "Groups": {
        "group1": {
            "DesiredVMCount": 3,
            "InstanceType": "",
            "ResourceType": "OnDemand",
            "SpotStrategy": "",
            "SpotPriceLimit": 0.0
        }
    },
    "Configs": {
        "Disks": {
            "SystemDisk": {
                "Type": "cloud_efficiency",
                "Size": 50
            },
            "DataDisk": {
                "Type": "cloud_efficiency",
                "Size": 500,
                "MountPoint": "/home/my-data-disk"
            }
        },
        "Mounts": {
            "Locale": "GBK",
            "Lock": false,
            "CacheSupport": true,
            "CacheBlockSize": 262144,
            "CacheTotalSize": 536870912,
            "OSS": {
                "AccessKeyId": "[OSS Access Key Id]",
                "AccessKeySecret": "[OSS Access Key Id Secret]",
                "SecurityToken": ""
            },
            "Entries": [
                {
                    "Source": "nas://26a174a62f-sfi98.cn-shenzhen.nas.aliyuncs.com:/",
                    "Destination": "/home/admin/mydir1/",
                    "WriteSupport": true
                },
                {
                    "Source": "oss://my-test-bk/",
                    "Destination": "/home/admin/mydir3/",
                    "WriteSupport": false
                }
            ]
        },
        "Networks": {
            "VPC": {
                "VpcId": "[Your vpc id]",
                "CidrBlock": "192.168.0.0/16"
            },
            "Classic": {
                "AllowIpAddress": [],
                "AllowIpAddressEgress": [],
                "AllowSecurityGroup": [],
                "AllowSecurityGroupEgress": []
            }
        }
    }
}

属性说明:

属性名称

类型

是否必须

描述

Name

string

集群名称。长度为[2, 128]个英文或中文字符。必须以大小字母或中文开头,不能以 http:// 和https:// 开头。可以包含数字、半角冒号(:)、下划线(_)或者连字符(-)。

Description

string

集群的描述信息。长度为[2, 256]个英文或中文字符。必须以大小字母或中文开头,不能以 http:// 和 https:// 开头。可以包含数字、半角冒号(:)、下划线(_)或者连字符(-)

InstanceType

string

构建集群的实例类型。目前支持的ECS实例类型参阅 实例类型

ImageId

string

镜像标识符。您可以使用官方定义的或自定义的镜像。可以通过 获取镜像列表 获取您可使用的所有镜像标识符。

DependencyIsvService

string

执行程序依赖的阿里云提供的ISV服务,目前提供的ISV服务有:“GTX”,默认为空不依赖任何ISV服务。

Bootstrap

string

实例启动运行的命令。您可以指定Bootstrap来初始化您的环境。Bootstrap 与 JOB 指定的程序运行命令有区别,JOB指定的程序是用来运行您的作业。

UserData

map<string, string>

用户自定义的信息,您可以定义 map 的 key 和 value 值。用户程序使用 ECS 的 user server 获取。

EnvVars

map<string, string>

虚拟机的环境变量,您可以定义 map 的 key 和 value 值。用户程序从环境变量中获取。

Groups

map<string, object>

集群的实例组群信息。key 是您自定义的 group name, value 是 GroupDesc 类型。 一个集群可以包含多个实例组,实例组有数量限制,参阅 用户限额

Notification

object

用户指定消息通知配置。

Configs

object

集群的一些配置信息,比如实例的磁盘配置、网络和挂载路径。

返回信息

成功

状态行:

HTTP/1.1 201 Created

响应数据:

{
    "Id":"cls-6ki3sg6sqlno7nt8fu0007"
}

属性说明:

属性名称

类型

是否必须

描述

Id

string

作业标识符。每个集群都有唯一的集群标识符,你需要通过集群标识符来管理您的集群。

错误

错误响应格式请参阅 返回结果

创建集群特有的错误码:

状态码

错误码

错误信息

语义

400

IdempotentTokenMismatch

Specified idempotent token mismatch.

说明该token已经被使用过,并且该请求参数与之前的请求不一样。

400

InvalidJsonFormat

The request body has an invalid json format.

请求body是一个非法的JSON格式。

400

InvalidHttpBody

Specified parameter HttpBody is not valid. Its type must be object.

http body必须是一个object。

400

MissingName

Name is mandatory for this action.

缺少Name参数。

400

MissingConfigs.Networks.VPC.OppositeRouterId

Configs.Networks.VPC.OppositeRouterId is mandatory for this action.

缺少Configs.Networks.VPC.OppositeRouterId参数。

400

MissingConfigs.Networks.VPC.OppositeAccessPointId

Configs.Networks.VPC.OppositeAccessPointId is mandatory for this action.

缺少Configs.Networks.VPC.OppositeAccessPointId参数。

400

MissingConfigs.Networks.VPC.OppositeRegionId

Configs.Networks.VPC.OppositeRegionId is mandatory for this action.

缺少Configs.Networks.VPC.OppositeRegionId参数。

400

InvalidName

Specified parameter Name is not valid. Its type must be string.

Name必须是一个string。

400

InvalidName

Specified parameter Name is not valid. Its length must be in [1, 64].

Name的长度必须在164之间。

400

InvalidName

Specified parameter Name is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9].

Name中只能包括字母数字和_-,但不能以数字开头。

400

InvalidDescription

Specified parameter Description is not valid. Its type must be string.

Description必须是一个string。

400

InvalidDescription

Specified parameter Description is not valid. Its length must be in [0, 1024].

Description的长度必须在01024之间。

400

MissingImageId

ImageId is mandatory for this action.

缺少ImageId参数。

400

InvalidImageId

Specified parameter ImageId is not valid. Its type must be string.

ImageId必须是一个string。

400

InvalidImageId

Specified parameter ImageId is not valid. Its length must be in [1, 256].

ImageId的长度必须在1256之间。

400

InvalidUserData

Specified parameter UserData is not valid. Its type must be object.

UserData必须是一个object。

400

InvalidUserData

Specified parameter UserData is not valid. Its size must be in [0, 64].

UserData的大小必须在064之间。

400

InvalidUserData.{key}

Specified parameter UserData.{key} is not valid. Its length must be in [1, 128].

UserData.{key}的大小必须在1128之间。

400

InvalidUserData.{key}.value

Specified parameter UserData.{key}.value is not valid. Its type must be string.

UserData.{key}对应的Value必须是一个string。

400

InvalidUserData.{key}.value

Specified parameter UserData.{key}.value is not valid. Its length must be in [0, 1024].

UserData.{key}对应的value的长度必须在01024之间。

400

InvalidGroups

Specified parameter Groups is not valid. Its type must be object.

Groups必须是一个object。

400

InvalidGroups.{key}

Specified parameter Groups.{key} is not valid. Its type must be object.

Groups.{key}必须是一个object。

400

InvalidGroups.{key}

Specified parameter Groups.{key} is not valid. Its size must be in [1, 64].

Groups.{key}的大小必须在164之间。

400

MissingDesiredVMCount

DesiredVMCount is mandatory for this action.

缺少DesiredVMCount参数。

400

InvalidDesiredVMCount

Specified parameter DesiredVMCount is not valid. Its type must be integer.

DesiredVMCount必须是一个integer。

400

InvalidDesiredVMCount

Specified parameter DesiredVMCount is not valid. It must be in [1, 65536].

DesiredVMCount的大小必须在165536之间。

400

InvalidCidrBlock

Specified parameter CidrBlock is not valid. Configs.Networks.VPC.CidrBlock is not valid.

无效的CidrBlock。

403

QuotaExhausted.MaxClusterCount

The MaxClusterCount ({value}) quota is exhausted.

Cluster数量不能超过{value}。

403

QuotaExhausted.MaxClusterGroupCount

The MaxClusterGroupCount ({value}) quota is exhausted.

一个Cluster中的Group的数量不能超过{value}。

403

QuotaExhausted.MaxClusterGroupDesiredVMCount

The MaxClusterGroupDesiredVMCount ({value}) quota is exhausted.

一个Cluster中的一个GroupDesiredVMCount不能超过{value}。

403

QuotaExhausted.Configs.Networks.VPC.OppositeRouterType

The Configs.Networks.VPC.OppositeRouterType ({value}) is forbidden.

Configs.Networks.VPC.OppositeRouterType不允许取值{value}。

400

MissingInstanceType

InstanceType is mandatory for this action.

缺少InstanceType参数。

400

InvalidInstanceType

Specified parameter InstanceType is not valid.

InstanceType参数取值不合法。

400

MissingResourceType

ResourceType is mandatory for this action.

缺少ResourceType参数。

400

InvalidResourceType

Specified parameter ResourceType is not valid.

ResourceType参数取值不合法。

400

Invalid{Parameter}

Specified parameter {Parameter} is not valid.

{Parameter}参数不合法。