
# 创建边缘集群
#### 功能介绍
应用服务器可调用此接口为创建边缘集群。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/IoTEdge/doc?api=CreateClusterV3)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### URI
POST /v3/{project_id}/clusters
表1路径参数 
| 参数         | 是否必选 | 参数类型   | 描述                                                                                        |
|:---|:---|:---|:---|
| project_id | 是    | String | 项目ID。获取方法请参见 [获取项目ID](https://support.huaweicloud.com/api-iotedge/iotedge_api_0032.html)。 |
   
#### 请求参数
表2请求Header参数 
| 参数           | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|
| X-Auth-Token | 是    | String | 用户Token。通过调用IAM服务 [获取IAM用户Token](https://support.huaweicloud.com/api-iam/iam_30_0001.html)接口获取，接口返回的响应消息头中"X-Subject-Token"就是需要获取的用户Token。简要的获取方法样例请参见 [Token认证](https://support.huaweicloud.com/api-iothub/iot_06_v5_0091.html#section0)。 |
   
表3请求Body参数 
| 参数                  | 是否必选 | 参数类型                                                                                                              | 描述     |
|:---|:---|:---|:---|
| cluster_name        | 是    | String                                                                                                            | 集群名称   |
| description         | 否    | String                                                                                                            | 集群描述   |
| cluster_node_config | 否    | [ClusterNodeConfig] object | 集群节点配置 |
| cluster_type        | 否    | String                                                                                                            | 集群类型   |
   
 表4ClusterNodeConfig 
| 参数              | 是否必选 | 参数类型                                                                                                          | 描述               |
|:---|:---|:---|:---|
| master_node_vip | 否    | String                                                                                                        | master虚拟ip       |
| dmz_vip         | 否    | String                                                                                                        | dmz区worker节点虚拟ip |
| interface_name  | 否    | String                                                                                                        | 网卡名称             |
| master_nodes    | 否    | Array of [NodeConfig] objects | master节点数        |
| dmz_nodes       | 否    | Array of [NodeConfig] objects | dmz区worker节点数    |
| work_nodes      | 否    | Array of [NodeConfig] objects | trust区worker节点数  |
   
 表5NodeConfig 
| 参数        | 是否必选 | 参数类型   | 描述   |
|:---|:---|:---|:---|
| node_ip   | 否    | String | 节点IP |
| node_name | 否    | String | 节点名称 |
   
#### 响应参数
**状态码：201**
表6响应Body参数 
| 参数             | 参数类型    | 描述       |
|:---|:---|:---|
| cluster_id     | String  | 集群ID     |
| cluster_name   | String  | 集群名称     |
| description    | String  | 集群描述     |
| version        | String  | 边缘集群版本   |
| state          | String  | 边缘集群状态   |
| is_upgradeable | Boolean | 是否可升级    |
| cluster_type   | String  | 集群类型     |
| cluster_addr   | String  | 集群地址     |
| create_time    | String  | 创建时间     |
| update_time    | String  | 最后一次修改时间 |
   
#### 请求示例
```
GET https://{endpoint}/v3/{project_id}/clusters
{
  "cluster_name" : "test-cluster",
  "description" : "this is a test cluster",
  "cluster_node_config" : {
    "master_node_vip" : "string",
    "master_nodes" : [ {
      "node_ip" : "string",
      "node_name" : "string"
    } ],
    "work_nodes" : [ {
      "node_ip" : "string",
      "node_name" : "string"
    } ]
  }
}
```
#### 响应示例
**状态码：201**
Created
```
{
  "cluster_id" : "123343534",
  "cluster_name" : "test-cluster",
  "description" : "this is a test cluster",
  "version" : "string",
  "state" : "string",
  "create_time" : "string",
  "update_time" : "string",
  "is_upgradeable" : true
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 201 | Created               |
| 400 | BAD REQUEST           |
| 401 | Unauthorized          |
| 403 | FORBIDDEN             |
| 500 | Internal Server Error |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-iotedge/ErrorCode.html)。
