
# 创建应用部署
#### 功能介绍
该API用于部署一个或多个应用到一组边缘节点。
#### URI
POST /v2/{project_id}/edgemgr/deployments
表1Path参数 
| 名称         | 是否必选 | 说明                                                                            |
|:---|:---|:---|
| project_id | 是    | 项目ID，获取方法请参见[获取项目ID](https://support.huaweicloud.com/api-ief/projectid.html)。 |
   
#### 请求消息
**请求参数**
表2请求Header参数 
| 参数           | 是否必选 | 类型     | 描述                                                                                                                                                                                                                                                       |
|:---|:---|:---|:---|
| Content-Type | 是    | String | 消息体的类型（格式） 推荐您使用默认值application/json。                                                                                                                                                                  |
| X-Auth-Token | 是    | String | 用户Token 调用接口的认证方式分为Token和AK/SK两种，如果您使用Token方式，此参数为必填，请填写Token的值，获取方式请参见[Token认证](https://support.huaweicloud.com/api-ief/ief_02_0011.html#ief_02_0011__zh-cn_topic_0121671869_section2417768214391)。 |
   
表3请求Body参数 
| 名称          | 是否必选 | 参数类型                                            | 说明                                                             |
|:---|:---|:---|:---|
| name        | 是    | String                                          | 应用部署名称，只允许英文小写字母、数字、中划线，最大长度64，英文小写字母或数字开头和结尾。                 |
| description | 否    | String                                          | 应用部署描述，最大长度255，不允许\^ \~ # $ % \& \* \< \> ( ) \[ \] { } ' " \\ |
| node_ids    | 是    | Array of strings                                | 边缘节点ID列表，当前只支持一个边缘节点                                           |
| app         | 是    | [表4] object | 应用配置                                                           |
| group_id    | 否    | String                                          | 边缘节点组                                                          |
| visibility  | 否    | String                                          | 预留字段                                                           |
   
 表4app 
| 名称                 | 是否必选 | 参数类型                                                                                                           | 说明                                                 |
|:---|:---|:---|:---|
| name               | 是    | String                                                                                                         | 应用名称（预留字段），只允许英文小写字母、数字、中划线，最大长度64，英文小写字母或数字开头和结尾。 |
| version            | 否    | String                                                                                                         | 版本描述，只允许英文小写字母、数字、中划线、点，最大长度64，英文小写字母或数字开头。        |
| image_url          | 是    | String                                                                                                         | 容器镜像URL，最大长度2083，不能为空字符串。                          |
| envs               | 否    | Array of [表10](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__Env) objects              | 环境变量                                               |
| volumes            | 否    | Array of [表11](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table76733481596) objects | 卷配置                                                |
| resources          | 否    | [表12](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table3625182923310) object         | 容器资源配置                                             |
| configs            | 否    | [表14](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table3737172514512) object         | 高级配置                                               |
| liveness_probe     | 否    | [表15](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table796418321608) object          | 工作负载存活探针，如果不需要，请求消息体中不需要提供该字段                      |
| readiness_probe    | 否    | [表15](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table796418321608) object          | 工作负载业务探针，如果不需要，请求消息体中不需要提供该字段                      |
| command            | 否    | Array of String                                                                                                | 容器命令                                               |
| toleration_seconds | 否    | Integer                                                                                                        | 应用实例故障容忍时间，容忍时间到达后迁移应用实例，只在指定节点组部署时生效              |
| migration          | 否    | Boolean                                                                                                        | 应用实例故障是否迁移，指定节点组部署时必选，默认值false                     |
| args               | 否    | Array of String                                                                                                | 参数                                                 |
   
**请求示例**
```
{
    "deployment": {
        "name": "deployment-test",
        "description": "This is a test deployment",
        
        "node_ids": [
            "09dafd3e-63df-47a8-b7c6-119563fefa85"
        ],
        "app": {
            "name": "test-hw",
            "version": "1.0.0",
            "image_url": "100.95.181.176:5300/op_svc_ief_container1/sample:latest",
            "envs": [],
            "volumes": [],
            "configs": {
                "privileged": false,
                "host_network": false,
                "restart_policy": "Always",
                "ports": [
                    {
                        "container_port": 8888,
                        "host_port": 88
                    }
                ]
            },
            "resources": {
                "requests": {
                    "cpu": 0.25,
                    "memory": 512
                },
                "limits": {
                    "cpu": 1,
                    "memory": 512
                }
            },
            "liveness_probe": {
                "exec_command": "/bin/bash",
                "initial_delay_seconds": 10,
                "timeout_seconds": 10
            }
        }
    }
}
```
#### 响应消息
**响应参数**
表5响应Body参数 
| 名称         | 参数类型                                                                                                  | 说明     |
|:---|:---|:---|
| deployment | [表18](https://support.huaweicloud.com/api-ief/ief_02_1001.html#ief_02_1001__table136713167268) object | 部署详细信息 |
   
**响应示例**
```
{
    "deployment": {
        "description": "This is a test deployment",
        "created_at": "2019-07-10T07:12:44.020393",
        "updated_at": null,
        "visibility": null,
        "instances": [
            {
                "restarts": 0,
                "name": "test-hw",
                "envs": [],
                "liveness_probe": {
                    "timeout_seconds": 10,
                    "exec_command": "/bin/bash",
                    "initial_delay_seconds": 10
                },
                "state": "PENDING_CREATE",
                "group_name": null,
                "configs": {
                    "host_network": false,
                    "restart_policy": "Always",
                    "privileged": false,
                    "ports": [
                        {
                            "host_port": 88,
                            "container_port": 8888
                        }
                    ]
                },
                "reason": null,
                "version": "1.0.0",
                "image_url": "100.95.181.176:5300/op_svc_ief_container1/sample:latest",
                "resources": {
                    "requests": {
                        "cpu": 0.25,
                        "memory": 512.0
                    },
                    "limits": {
                        "cpu": 1.0,
                        "memory": 512.0
                    }
                },
                "volumes": [],
                "is_ready": null,
                "readiness_probe": null,
                "message": null,
                "group_id": null,
                "id": "f4f87339-fe33-483a-a838-6d5250a96fc5",
                "node_id": "09dafd3e-63df-47a8-b7c6-119563fefa85"
            }
        ],
        "project_id": "9ff38382ccc546ac9635800c3315a5e2",
        "id": "8170e363-0232-44eb-b89c-dab6b6e915ff",
        "name": "deployment-test"
    }
}
```
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-ief/ErrorCode.html)。
