
# 创建组件配置 - CreateComponentConfiguration
#### 功能介绍
创建组件配置。
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/CAE/doc?api=CreateComponentConfiguration)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-cae/cae_06_0016.html)。
- 如果使用身份策略授权，当前API调用无需身份策略权限。
#### URI
POST /v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
表1路径参数 
| 参数             | 是否必选 | 参数类型   | 描述                                                                                |
|:---|:---|:---|:---|
| project_id     | 是    | String | 项目ID，获取项目ID请参见[获取项目ID](https://support.huaweicloud.com/api-cae/cae_06_0021.html)。 |
| application_id | 是    | String | 应用ID。                                                                             |
| component_id   | 是    | String | 组件ID。                                                                             |
#### 请求参数
表2请求Header参数 
| 参数                      | 是否必选 | 参数类型   | 描述                                                                                                                                                                                                                             |
|:---|:---|:---|:---|
| X-Auth-Token            | 是    | String | 用户Token。 - 获取Token，请参考《[统一身份认证服务API参考](https://support.huaweicloud.com/api-iam/iam_30_0001.html)》的"获取用户Token"章节。 - 请求响应成功后在响应消息头中包含的"X-Subject-Token"的值即为Token值。                                                               |
| X-Enterprise-Project-ID | 否    | String | 企业项目ID。 - 创建环境时，环境会绑定企业项目ID。 - 最大长度36字节，带"-"连字符的UUID格式，或者是字符串"0"。 - 该字段不传（或传为字符串"0"）时，则查询默认企业项目下的资源。 说明： 关于企业项目ID的获取及企业项目特性的详细信息，请参见《[企业管理服务用户指南](https://support.huaweicloud.com/usermanual-em/zh-cn_topic_0126101490.html)》。 |
| X-Environment-ID        | 是    | String | 环境ID。 - 获取环境ID，通过[获取环境列表](https://support.huaweicloud.com/api-cae/ListEnvironments.html)来获取环境信息。 - 请求响应成功后在响应体的items数组中的一个元素即为一个环境的信息，其中id字段即是环境ID。                                                                            |
   
表3请求Body参数 
| 参数          | 是否必选 | 参数类型                                                                                           | 描述                                        |
|:---|:---|:---|:---|
| api_version | 是    | String                                                                                         | API版本，固定值"v1"，该值不可修改。                     |
| kind        | 是    | String                                                                                         | API类型，固定值"ComponentConfiguration"，该值不可修改。 |
| items       | 是    | Array of [ConfigurationItem] objects | 配置项列表。                                    |
   
 表4ConfigurationItem 
| 参数   | 是否必选 | 参数类型                                                                                 | 描述                                                                                                                                                                                                                                |
|:---|:---|:---|:---|
| type | 是    | String                                                                               | **参数解释：** 组件配置类型。 **约束限制：** 不涉及。 **取值范围：** - rds：云数据库RDS - cse：微服务引擎CSE - env：环境变量 - access：访问方式 - scaling：伸缩策略 - volume：云存储配置 - healthCheck：健康检查 - lifecycle：生命周期管理 - apm2：性能管理 - log：日志采集 - customMetric：自定义监控指标 **默认取值：** 不涉及。 |
| data | 是    | [ConfigurationData] object | 组件配置数据。                                                                                                                                                                                                                           |
   
 表5ConfigurationData 
| 参数       | 是否必选 | 参数类型                                                                                                       | 描述          |
|:---|:---|:---|:---|
| spec     | 否    | [ConfigurationRequestDataSpec] object | 组件配置数据规格详情。 |
| metadata | 否    | [ConfigurationDataMetadata] object       | 组件配置元数据。    |
   
 表6ConfigurationRequestDataSpec 
| 参数                      | 是否必选 | 参数类型                                                                                                                           | 描述                                                                                                                      |
|:---|:---|:---|:---|
| rds_id                  | 否    | String                                                                                                                         | RDS数据库实例ID。 ConfigurationItem.type为"rds"时，配置此参数。                                                                        |
| rds_db_name             | 否    | String                                                                                                                         | RDS数据库名称。 ConfigurationItem.type为"rds"时，配置此参数。                                                                          |
| rds_address             | 否    | String                                                                                                                         | RDS数据库地址。 ConfigurationItem.type为"rds"时，配置此参数。                                                                          |
| rds_username            | 否    | String                                                                                                                         | RDS数据库用户名称。 ConfigurationItem.type为"rds"时，配置此参数。                                                                        |
| rds_password            | 否    | String                                                                                                                         | RDS数据库密码。 ConfigurationItem.type为"rds"时，配置此参数。                                                                          |
| rds_port                | 否    | String                                                                                                                         | RDS数据库端口。 ConfigurationItem.type为"rds"时，配置此参数。                                                                          |
| config_center_addr      | 否    | String                                                                                                                         | CSE配置中心地址。 ConfigurationItem.type为"cse"时，配置此参数。                                                                         |
| service_center_addr     | 否    | String                                                                                                                         | CSE服务注册发现地址。 ConfigurationItem.type为"cse"时，配置此参数。                                                                       |
| cse_id                  | 否    | String                                                                                                                         | CSE引擎ID。 ConfigurationItem.type为"cse"时，配置此参数。                                                                           |
| envs                    | 否    | Map\<String,String\>                                                                                                           | 手动添加环境变量配置。 常用环境变量如下： - TZ: 时区设置，东八区可设置为Asia/Shanghai。 - LANG: 语言字符集设置，中文UTF8可设置为zh_CN.UTF-8。                           |
| ip                      | 否    | String                                                                                                                         | 弹性公网IP，响应体参数，未配置域名时返回此参数。                                                                                               |
| items                   | 否    | Array of [AccessConfigurationDataItems] objects           | 访问方式配置列表。 ConfigurationItem.type为"access"时，配置此参数。                                                                       |
| switch                  | 否    | String                                                                                                                         | 伸缩策略配置开关。 ConfigurationItem.type为"scaling"时，配置此参数。                                                                      |
| scale_strategy          | 否    | String                                                                                                                         | **参数解释：** 伸缩策略配置策略类型。 **约束限制：** ConfigurationItem.type为"scaling"时，配置此参数。 **取值范围：** - metric：指标策略 - time：时间策略 - mix：混合策略 |
| max_replica_count       | 否    | Integer                                                                                                                        | 伸缩策略配置最大伸缩个数。 ConfigurationItem.type为"scaling"时，配置此参数。                                                                  |
| min_replica_count       | 否    | Integer                                                                                                                        | 伸缩策略配置最小伸缩个数。 ConfigurationItem.type为"scaling"时，配置此参数。                                                                  |
| advanced                | 否    | [ScaleConfigurationDataAdvanced] object                 | 伸缩策略高级配置。 ConfigurationItem.type为"scaling"时，配置此参数。                                                                      |
| triggers                | 否    | Array of [ScaleConfigurationDataTrigger] objects         | 伸缩策略配置触发器列表。 ConfigurationItem.type为"scaling"时，配置此参数。                                                                   |
| volumes                 | 否    | Array of [VolumeConfigurationDataVolume] objects         | 云存储配置列表。 ConfigurationItem.type为"volume"时，配置此参数。                                                                        |
| livenessProbe           | 否    | [HealthCheckConfigurationLivenessProbe] object   | 组件健康检查配置的存活探针配置。 ConfigurationItem.type为"healthCheck"时，配置此参数。                                                           |
| startupProbe            | 否    | [HealthCheckConfigurationStartupProbe] object     | 组件健康检查配置的启动探针配置。 ConfigurationItem.type为"healthCheck"时，配置此参数。                                                           |
| readinessProbe          | 否    | [HealthCheckConfigurationReadinessProbe] object | 组件健康检查配置的就绪探针配置。 ConfigurationItem.type为"healthCheck"时，配置此参数。                                                           |
| postStart               | 否    | [postStart] object                                                           | 生命周期管理组件配置启动后处理。 ConfigurationItem.type为"lifecycle"时，配置此参数。                                                             |
| preStop                 | 否    | [preStop] object                                                               | 生命周期管理组件配置停止前处理。 ConfigurationItem.type为"lifecycle"时，配置此参数。                                                             |
| log_paths               | 否    | Array of strings                                                                                                               | 自定义本地磁盘日志路径数组。 ConfigurationItem.type为"log"时，配置此参数。                                                                     |
| cloud_storage_log_paths | 否    | Array of [CloudStorageLogPathInfo] objects                     | 自定义云存储日志路径数组。 ConfigurationItem.type为"log"时，配置此参数。                                                                      |
| multiline               | 否    | [multiline] object                                                           | 多行日志模式                                                                                                                  |
| instrumentation         | 否    | String                                                                                                                         | **参数解释：** 探针注入方式。 **约束限制：** ConfigurationItem.type为"apm2"时，配置此参数。 **取值范围：** - automatic：自动注入探针                          |
| path                    | 否    | String                                                                                                                         | 自定义监控指标配置采集路径。 ConfigurationItem.type为"customMetric"时，配置此参数。                                                            |
| port                    | 否    | Integer                                                                                                                        | 自定义监控指标配置采集端口。 ConfigurationItem.type为"customMetric"时，配置此参数。                                                            |
| metrics                 | 否    | Array of strings                                                                                                               | 自定义监控指标配置指标名称。 ConfigurationItem.type为"customMetric"时，配置此参数。                                                            |
   
 表7AccessConfigurationDataItems 
| 参数                | 是否必选 | 参数类型                                                                                                       | 描述                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| operator          | 否    | String                                                                                                     | 配置模式。 - 如果operator值为空，则表示使用全量覆盖模式进行配置，否则表示使用增删改模式进行配置。 - 当使用增删改模式时，operator取值支持"add","copy","modify","delete"，分别表示新增，复制指定uid的元素修改后新增，修改指定uid的元素，删除指定uid的元素。 - 当operator取值为"copy","modify","delete"时，uid的值必须为非空，且存在于最后一次生效的配置中。 - 当operator取值为"copy","modify"时，与operator同级别的字段中除uid外的所有字段如不写，置空或者为空列表，则表示保留在最后一次生效配置中指定uid的元素的同一字段的值。且此时此级列表以及其父级和子级列表的所有元素的operator值必须同时全为空或者非空。 |
| uid               | 否    | String                                                                                                     | 访问方式的uid。                                                                                                                                                                                                                                                                                                                                                                        |
| metadata          | 否    | [AccessConfigurationMetadata] object   | 访问方式配置元数据。                                                                                                                                                                                                                                                                                                                                                                       |
| type              | 否    | String                                                                                                     | **参数解释：** 访问方式类型。 **取值范围：** - ClusterIP：集群内部IP访问方式 - LoadBalancer：负载均衡访问方式 - Ingress：路由访问方式 **默认取值：** 不涉及。                                                                                                                                                                                                                                                                       |
| sub_type          | 否    | String                                                                                                     | 访问方式子类型。                                                                                                                                                                                                                                                                                                                                                                         |
| ingress_config_id | 否    | String                                                                                                     | 访问关联域名后缀ID，多个域名后缀逗号隔开。                                                                                                                                                                                                                                                                                                                                                           |
| domain_names      | 否    | Array of strings                                                                                           | 内网访问方式域名。                                                                                                                                                                                                                                                                                                                                                                        |
| access_control    | 否    | [AccessControl] object                               | 访问控制配置，允许配置黑名单、白名单。                                                                                                                                                                                                                                                                                                                                                              |
| ports             | 否    | Array of [AccessConfigurationPort] objects | 访问方式配置端口、协议、证书、URL路径等信息列表。                                                                                                                                                                                                                                                                                                                                                       |
| elb_id            | 否    | String                                                                                                     | 用户选择的elb的ID。                                                                                                                                                                                                                                                                                                                                                                     |
| public_ip         | 否    | String                                                                                                     | 响应体参数，用户选择的elb的公网ip。                                                                                                                                                                                                                                                                                                                                                             |
| private_ip        | 否    | String                                                                                                     | 响应体参数，用户选择的elb的私网ip。                                                                                                                                                                                                                                                                                                                                                             |
   
 表8AccessConfigurationMetadata 
| 参数          | 是否必选 | 参数类型                 | 描述                                                                                                                                       |
|:---|:---|:---|:---|
| annotations | 否    | Map\<String,String\> | 附加参数。 举例：负载均衡分配策略使用加权轮询算法，不启用健康检查。配置如下： - "kubernetes.io/elb.health-check-flag": "off" - "kubernetes.io/elb.lb-algorithm": "ROUND_ROBIN" |
   
 表9AccessControl 
| 参数    | 是否必选 | 参数类型             | 描述                                                     |
|:---|:---|:---|:---|
| black | 否    | Array of strings | 黑名单数组。 - 每行一个IP地址或网段，以回车结束。 - 每个IP地址组最多可添加300个IP地址或网段。 |
| white | 否    | Array of strings | 白名单数组。 - 每行一个IP地址或网段，以回车结束。 - 每个IP地址组最多可添加300个IP地址或网段。 |
   
 表10AccessConfigurationPort 
| 参数                  | 是否必选 | 参数类型                                                                                                               | 描述                                                                                                                                                                                                                                                                                                                                                                               |
|:---|:---|:---|:---|
| operator            | 否    | String                                                                                                             | 配置模式。 - 如果operator值为空，则表示使用全量覆盖模式进行配置，否则表示使用增删改模式进行配置。 - 当使用增删改模式时，operator取值支持"add","copy","modify","delete"，分别表示新增，复制指定uid的元素修改后新增，修改指定uid的元素，删除指定uid的元素。 - 当operator取值为"copy","modify","delete"时，uid的值必须为非空，且存在于最后一次生效的配置中。 - 当operator取值为"copy","modify"时，与operator同级别的字段中除uid外的所有字段如不写，置空或者为空列表，则表示保留在最后一次生效配置中指定uid的元素的同一字段的值。且此时此级列表以及其父级和子级列表的所有元素的operator值必须同时全为空或者非空。 |
| uid                 | 否    | String                                                                                                             | 端口配置的uid。                                                                                                                                                                                                                                                                                                                                                                        |
| target_port         | 否    | Integer                                                                                                            | 监听端口。                                                                                                                                                                                                                                                                                                                                                                            |
| port                | 否    | Integer                                                                                                            | 访问端口。                                                                                                                                                                                                                                                                                                                                                                            |
| protocol            | 否    | String                                                                                                             | 协议，负载均衡支持TCP，负载均衡与路由配置支持HTTP、HTTPS。                                                                                                                                                                                                                                                                                                                                              |
| default_certificate | 否    | String                                                                                                             | 默认证书，访问方式配置为转发策略且协议为HTTPS时配置，未配置域名证书对时使用默认证书。                                                                                                                                                                                                                                                                                                                                    |
| certificate         | 否    | String                                                                                                             | 证书。                                                                                                                                                                                                                                                                                                                                                                              |
| policy              | 否    | String                                                                                                             | 安全策略。                                                                                                                                                                                                                                                                                                                                                                            |
| paths               | 否    | Array of [AccessConfigurationHttpPath] objects | 匹配路径和域名信息。                                                                                                                                                                                                                                                                                                                                                                       |
| elb_id              | 否    | String                                                                                                             | 用户选择的elb的ID。                                                                                                                                                                                                                                                                                                                                                                     |
   
 表11AccessConfigurationHttpPath 
| 参数             | 是否必选 | 参数类型   | 描述                          |
|:---|:---|:---|:---|
| hostname       | 否    | String | 域名/不填，不填时表示使用IP。            |
| path           | 否    | String | URL路径。                      |
| url_match_mode | 否    | String | URL路径匹配模式，支持前缀匹配、正则匹配、精准匹配。 |
   
 表12ScaleConfigurationDataAdvanced 
| 参数                              | 是否必选 | 参数类型    | 描述        |
|:---|:---|:---|:---|
| scaledown_stabilization_seconds | 否    | Integer | 缩容冷却时间窗。  |
| scaledown_rate                  | 否    | Integer | 缩容步长。     |
| scaleup_stabilization_seconds   | 否    | Integer | 扩容冷却时间窗。  |
| scaleup_rate                    | 否    | Integer | 扩容步长。     |
| disable_scaledown               | 否    | Boolean | 是否禁用自动缩容。 |
   
 表13ScaleConfigurationDataTrigger 
| 参数       | 是否必选 | 参数类型                                                                                   | 描述                                                                                        |
|:---|:---|:---|:---|
| type     | 否    | String                                                                                 | **参数解释：** 指标类型。 **取值范围：** - cpu：cpu指标 - memory：内存指标 - cron：定时指标 - prometheus：prometheus指标 |
| metadata | 否    | [ScalingTriggerMeta] object | trigger元数据。                                                                               |
   
 表14ScalingTriggerMeta 
| 参数          | 是否必选 | 参数类型                                                                                                 | 描述                                                                                                                                                                                                |
|:---|:---|:---|:---|
| type        | 否    | String                                                                                               | 数据类型，当前只支持利用率，默认值为Utilization。 ScaleConfigurationDataTrigger.type为"cpu、memory"时，配置此参数。                                                                                                            |
| value       | 否    | String                                                                                               | 触发指标的阈值。 ScaleConfigurationDataTrigger.type为"cpu、memory"时，配置此参数。                                                                                                                                  |
| period_type | 否    | String                                                                                               | **参数解释：** 生效周期。 ScaleConfigurationDataTrigger.type为"cron"时，配置此参数。 **取值范围：** - day：按每天为周期进行配置弹性伸缩策略，例如每天定时7AM - week：按周为周期进行配置弹性伸缩策略，例如每周三定时7AM - month：按月为周期进行配置弹性伸缩策略，例如每月1号定时7AM **默认取值：** 不涉及。 |
| schedulers  | 否    | Array of [CronTriggerScheduler] objects | 每个周期内触发的时间点和实例数。 ScaleConfigurationDataTrigger.type为"cron"时，配置此参数。                                                                                                                                |
   
 表15CronTriggerScheduler 
| 参数             | 是否必选 | 参数类型    | 描述                  |
|:---|:---|:---|:---|
| cron           | 否    | String  | 触发时间点，以五位cron表达式表示。 |
| target_replica | 否    | Integer | 要求达到的实例数。           |
   
 表16VolumeConfigurationDataVolume 
| 参数                | 是否必选 | 参数类型                                                                                                                 | 描述                                                                                                                     |
|:---|:---|:---|:---|
| volume_id         | 否    | String                                                                                                               | 云存储ID。                                                                                                                 |
| resource_name     | 否    | String                                                                                                               | 云存储名称。                                                                                                                 |
| resource_type     | 否    | String                                                                                                               | **参数解释：** 云存储类型。 **取值范围：** - obs：obs存储桶、并行文件系统，填该值。 - sfs：通用文件系统、高性能弹性文件服务，填该值。                                        |
| resource_sub_type | 否    | String                                                                                                               | **参数解释：** 云存储子类型。 **取值范围：** - object_bucket：obs存储桶 - parallel_file_system：并行文件系统 - sfs3.0：通用文件系统 - sfs_turbo：高性能弹性文件服务 |
| umask             | 否    | String                                                                                                               | 设置目录或文件缺省权限，默认值0027，sfs3.0类型的云存储不支持配置此参数。                                                                              |
| mount_info        | 否    | Array of [VolumeConfigurationMountInfo] objects | 云存储配置挂载信息。                                                                                                             |
   
 表17VolumeConfigurationMountInfo 
| 参数          | 是否必选 | 参数类型   | 描述      |
|:---|:---|:---|:---|
| path        | 否    | String | 容器挂载路径。 |
| sub_path    | 否    | String | 子路径。    |
| access_mode | 否    | String | 读写权限。   |
   
 表18HealthCheckConfigurationLivenessProbe 
| 参数                  | 是否必选 | 参数类型                                                                                                                 | 描述                 |
|:---|:---|:---|:---|
| periodSeconds       | 否    | Integer                                                                                                              | 检测周期，单位为s。         |
| initialDelaySeconds | 否    | Integer                                                                                                              | 延迟时间，单位为s。         |
| timeoutSeconds      | 否    | Integer                                                                                                              | 超时时间，单位为s。         |
| successThreshold    | 否    | Integer                                                                                                              | 成功阈值。              |
| failureThreshold    | 否    | Integer                                                                                                              | 最大失败次数。            |
| httpGet             | 否    | [HealthCheckConfigurationHttpGet] object     | 健康检查配置中HTTP请求检查信息。 |
| tcpSocket           | 否    | [HealthCheckConfigurationTcpSocket] object | 健康检查配置中TCP端口检查信息。  |
| exec                | 否    | [HealthCheckConfigurationExec] object           | 健康检查配置中执行命令检查。     |
   
 表19HealthCheckConfigurationStartupProbe 
| 参数                  | 是否必选 | 参数类型                                                                                                                 | 描述                 |
|:---|:---|:---|:---|
| periodSeconds       | 否    | Integer                                                                                                              | 检测周期，单位为s。         |
| initialDelaySeconds | 否    | Integer                                                                                                              | 延迟时间，单位为s。         |
| timeoutSeconds      | 否    | Integer                                                                                                              | 超时时间，单位为s。         |
| successThreshold    | 否    | Integer                                                                                                              | 成功阈值。              |
| failureThreshold    | 否    | Integer                                                                                                              | 最大失败次数。            |
| httpGet             | 否    | [HealthCheckConfigurationHttpGet] object     | 健康检查配置中HTTP请求检查信息。 |
| tcpSocket           | 否    | [HealthCheckConfigurationTcpSocket] object | 健康检查配置中TCP端口检查信息。  |
| exec                | 否    | [HealthCheckConfigurationExec] object           | 健康检查配置中执行命令检查。     |
   
 表20HealthCheckConfigurationReadinessProbe 
| 参数                  | 是否必选 | 参数类型                                                                                                                 | 描述                 |
|:---|:---|:---|:---|
| periodSeconds       | 否    | Integer                                                                                                              | 检测周期，单位为s。         |
| initialDelaySeconds | 否    | Integer                                                                                                              | 延迟时间，单位为s。         |
| timeoutSeconds      | 否    | Integer                                                                                                              | 超时时间，单位为s。         |
| successThreshold    | 否    | Integer                                                                                                              | 成功阈值。              |
| failureThreshold    | 否    | Integer                                                                                                              | 最大失败次数。            |
| httpGet             | 否    | [HealthCheckConfigurationHttpGet] object     | 健康检查配置中HTTP请求检查信息。 |
| tcpSocket           | 否    | [HealthCheckConfigurationTcpSocket] object | 健康检查配置中TCP端口检查信息。  |
| exec                | 否    | [HealthCheckConfigurationExec] object           | 健康检查配置中执行命令检查。     |
   
 表21HealthCheckConfigurationHttpGet 
| 参数     | 是否必选 | 参数类型    | 描述     |
|:---|:---|:---|:---|
| path   | 否    | String  | URL路径。 |
| port   | 否    | Integer | 端口。    |
| scheme | 否    | String  | 协议。    |
   
 表22HealthCheckConfigurationTcpSocket 
| 参数   | 是否必选 | 参数类型    | 描述  |
|:---|:---|:---|:---|
| port | 否    | Integer | 端口。 |
   
 表23HealthCheckConfigurationExec 
| 参数      | 是否必选 | 参数类型             | 描述       |
|:---|:---|:---|:---|
| command | 否    | Array of strings | shell语句。 |
   
 表24postStart 
| 参数   | 是否必选 | 参数类型                                                                                                   | 描述    |
|:---|:---|:---|:---|
| exec | 否    | [LifeCycleConfigurationExec] object | 执行命令。 |
   
 表25preStop 
| 参数   | 是否必选 | 参数类型                                                                                                   | 描述    |
|:---|:---|:---|:---|
| exec | 否    | [LifeCycleConfigurationExec] object | 执行命令。 |
   
 表26LifeCycleConfigurationExec 
| 参数      | 是否必选 | 参数类型             | 描述       |
|:---|:---|:---|:---|
| command | 否    | Array of strings | shell语句。 |
   
 表27CloudStorageLogPathInfo 
| 参数                | 是否必选 | 参数类型   | 描述         |
|:---|:---|:---|:---|
| dir_path          | 否    | String | 容器挂载路径。    |
| file_name_pattern | 否    | String | 日志文件名匹配模式。 |
   
 表28multiline 
| 参数    | 是否必选 | 参数类型   | 描述                                                                       |
|:---|:---|:---|:---|
| mode  | 否    | String | **参数解释：** 多行日志的分行模式。 **取值范围：** - time：日志时间 - regular：正则模式                |
| value | 否    | String | mode为time：value如yyyy-MM-dd hh:mm:sspm.SSS ZZZZ；mode为regular:value则为正则表达式 |
   
 表29ConfigurationDataMetadata 
| 参数          | 是否必选 | 参数类型                 | 描述                                                                                                                                       |
|:---|:---|:---|:---|
| annotations | 否    | Map\<String,String\> | 附加参数。 举例：负载均衡分配策略使用加权轮询算法，不启用健康检查。配置如下： - "kubernetes.io/elb.health-check-flag": "off" - "kubernetes.io/elb.lb-algorithm": "ROUND_ROBIN" |
   
#### 响应参数
**状态码：200**
请求成功。
无
#### 请求示例
- 创建云数据库RDS组件配置，数据库名称为"cae"，地址为100.xx.xx.xxx，端口号为3306。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "rds",
      "data" : {
        "spec" : {
          "rds_id" : "a5fdee4cf88c4277a68688a014f444bdin01",
          "rds_db_name" : "cae",
          "rds_address" : "100.xx.xx.xxx",
          "rds_username" : "cae",
          "rds_password" : "xxx",
          "rds_port" : "3306"
        }
      }
    } ]
  }
  ```
- 创建微服务引擎CSE组件配置，配置中心地址："https://192.168.1.xxx:30103,https://192.168.1.xxx:30103"，服务注册发现地址："https://192.168.1.xxx:30100,https://192.168.1.xxx:30100"。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "cse",
      "data" : {
        "spec" : {
          "config_center_addr" : "https://192.168.1.xxx:30103,https://192.168.1.xxx:30103",
          "service_center_addr" : "https://192.168.1.xxx:30100,https://192.168.1.xxx:30100",
          "cse_id" : "25779525-1aac-44be-abda-f9164f1b41b8"
        }
      }
    } ]
  }
  ```
- 创建环境变量组件配置，配置时区为Asia/Shanghai，且注入一个名称为password的凭据作为环境变量。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "env",
      "data" : {
        "spec" : {
          "envs" : {
            "TZ" : "Asia/Shanghai"
          },
          "env_references" : [ {
            "env_name" : "env-test",
            "value_from" : {
              "name" : "env-test",
              "reference_type" : "dewSecret"
            }
          } ]
        }
      }
    } ]
  }
  ```
- 创建内网访问方式和负载均衡类型的外网访问方式组件配置。
  - 内网访问方式类型为ClusterIP，监听端口为80，访问端口为8080，协议为TCP。
  - 外网访问方式类型为LoadBalancer，监听端口为80，访问端口为9090，协议为TCP，配置白名单访问控制，仅允许170.126.0.0/16网段的用户访问。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "access",
      "data" : {
        "spec" : {
          "items" : [ {
            "type" : "ClusterIP",
            "ports" : [ {
              "target_port" : 80,
              "port" : 8080,
              "protocol" : "TCP"
            } ]
          }, {
            "type" : "LoadBalancer",
            "access_control" : {
              "type" : "white",
              "ip_list" : [ "170.126.0.0/16" ]
            },
            "elb_id" : "xxx",
            "ports" : [ {
              "target_port" : 80,
              "port" : 9090,
              "protocol" : "TCP"
            } ]
          } ]
        }
      }
    } ]
  }
  ```
- 创建转发策略类型的外网访问方式组件配置，如下请求示例配置了两条转发策略，两条策略的对外协议为HTTPS、负载均衡策略为默认策略，使用加权轮询算法、访问端口为8443，配置黑名单访问策略，不允许10.120.1.1和10.120.1.2这两个IP访问，安全策略为tls-1-2-strict，服务器默认证书是test。
  - 第一条转发策略域名设置为test.example.com，URL匹配规则为前缀匹配，匹配路径为/test1，监听端口设置为80，第一条访问策略未配置域名证书对，使用默认证书test。
  - 第二条转发策略域名设置为test.example.cn，URL匹配规则为前缀匹配，匹配路径为/test2，监听端口设置为80，第二条访问策略配置了域名证书对，使用域名证书对中的证书test1。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "access",
      "data" : {
        "spec" : {
          "items" : [ {
            "type" : "Ingress",
            "access_control" : {
              "type" : "black",
              "ip_list" : [ "10.120.1.1", "10.120.1.2" ]
            },
            "ports" : [ {
              "port" : 8443,
              "protocol" : "HTTPS",
              "default_certificate" : "test",
              "policy" : "tls-1-2-strict",
              "target_port" : 80,
              "paths" : [ {
                "path" : "/test1",
                "url_match_mode" : "STARTS_WITH",
                "hostname" : "test.example.com"
              } ]
            }, {
              "port" : 8443,
              "protocol" : "HTTPS",
              "default_certificate" : "test",
              "certificate" : "test1",
              "policy" : "tls-1-2-strict",
              "target_port" : 80,
              "paths" : [ {
                "path" : "/test2",
                "url_match_mode" : "STARTS_WITH",
                "hostname" : "test.example.cn"
              } ]
            } ]
          } ]
        },
        "metadata" : {
          "annotations" : {
            "kubernetes.io/elb.health-check-flag" : "off",
            "kubernetes.io/elb.lb-algorithm" : "ROUND_ROBIN"
          }
        }
      }
    } ]
  }
  ```
- 创建伸缩策略组件配置，配置最大实例数3个，最小实例数1个，cpu使用率30%，内存使用率30%，缩容冷却时间窗5分钟，每次最大缩容99个实例，最大扩容4个实例，禁止缩容功能关闭。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "scaling",
      "data" : {
        "spec" : {
          "scale_strategy" : "metric",
          "max_replica_count" : 3,
          "min_replica_count" : 1,
          "advanced" : {
            "scaledown_stabilization_seconds" : 300,
            "scaledown_rate" : 99,
            "scaleup_stabilization_seconds" : 0,
            "scaleup_rate" : 4,
            "disable_scaledown" : false
          },
          "triggers" : [ {
            "metadata" : {
              "type" : "Utilization",
              "value" : "30"
            },
            "type" : "cpu"
          }, {
            "metadata" : {
              "type" : "Utilization",
              "value" : "30"
            },
            "type" : "memory"
          } ]
        }
      }
    } ]
  }
  ```
- 创建云存储配置组件配置（OBS桶配置、OBS并行文件系统、SFS3.0容量型配置），配置存储桶，挂载路径为/tmp，权限设置为读写；配置并行文件系统，挂载路径为/temp，权限设置为读写。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "volume",
      "data" : {
        "spec" : {
          "volumes" : [ {
            "volume_id" : "bef119d0-c7d1-4b58-9794-8b74faf80a59",
            "resource_name" : "test-nacos",
            "resource_type" : "obs",
            "resource_sub_type" : "object_bucket",
            "umask" : "0027",
            "mount_info" : [ {
              "path" : "/tmp",
              "access_mode" : "ReadWriteMany"
            } ]
          }, {
            "mount_info" : [ {
              "path" : "/temp",
              "access_mode" : "ReadWriteMany"
            } ],
            "volume_id" : "a061934d-52e3-4b36-aea7-6c51879f84c9",
            "resource_name" : "test",
            "resource_type" : "obs",
            "resource_sub_type" : "parallel_file_system",
            "umask" : "0027"
          } ]
        }
      }
    } ]
  }
  ```
- 创建健康检查组件配置（配置存活探针、就绪探针、启动探针）。
  - 配置存活探针，类型为livenessProbe，检测周期10s，延迟时间1s，超时时间1s，成功阈值1，最大失败次数3，端口为80，协议HTTP，路径、请求头未设置。
  - 配置就绪探针，类型为readinessProbe，检测周期10s，延迟时间0s(0可不传)，超时时间1s，成功阈值1，最大失败次数3，端口为80，协议HTTP，路径、请求头未设置。
  - 配置启动探针，类型为startupProbe，检测周期10s，延迟时间0s(0可不传)，超时时间1s，成功阈值1，最大失败次数3，端口为80，协议HTTP，路径未设置，请求头设置x-auth-token。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "healthCheck",
      "data" : {
        "spec" : {
          "livenessProbe" : {
            "periodSeconds" : 10,
            "initialDelaySeconds" : 1,
            "timeoutSeconds" : 1,
            "successThreshold" : 1,
            "failureThreshold" : 3,
            "httpGet" : {
              "path" : "",
              "port" : 80,
              "httpHeaders" : [ ],
              "scheme" : "HTTP"
            }
          },
          "startupProbe" : {
            "periodSeconds" : 10,
            "timeoutSeconds" : 1,
            "successThreshold" : 1,
            "failureThreshold" : 3,
            "httpGet" : {
              "path" : "",
              "port" : 80,
              "httpHeaders" : [ {
                "name" : "x-auth-token",
                "value" : "xxx"
              } ],
              "scheme" : "HTTP"
            }
          },
          "readinessProbe" : {
            "periodSeconds" : 10,
            "timeoutSeconds" : 1,
            "successThreshold" : 1,
            "failureThreshold" : 3,
            "httpGet" : {
              "path" : "",
              "port" : 80,
              "httpHeaders" : [ ],
              "scheme" : "HTTP"
            }
          }
        }
      }
    } ]
  }
  ```
- 创建生命周期管理组件配置（配置启动后处理、停止前处理）。配置启动后命令脚本"/bin/sh -c "echo service start""，配置停止前命令脚本"/bin/sh -c "echo service end""。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "lifecycle",
      "data" : {
        "spec" : {
          "postStart" : {
            "exec" : {
              "command" : [ "/bin/sh", "-c", "echo service start" ]
            }
          },
          "preStop" : {
            "exec" : {
              "command" : [ "/bin/sh", "-c", "echo service end" ]
            }
          }
        }
      }
    } ]
  }
  ```
- 创建自定义日志配置，创建自定义路径"/var/log/error.log"。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "log",
      "data" : {
        "spec" : {
          "log_paths" : [ "/var/log/error.log" ]
        }
      }
    } ]
  }
  ```
- 创建性能管理配置，探针注入方式为自动注入。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "apm2",
      "data" : {
        "spec" : {
          "instrumentation" : "automatic"
        }
      }
    } ]
  }
  ```
- 创建自定义监控指标配置，采集路径为/metrics，采集端口为2112，指定一个自定义监控指标，名称为myapp_processed_ops_total。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "customMetric",
      "data" : {
        "spec" : {
          "path" : "/metrics",
          "port" : 2112,
          "metrics" : [ "myapp_processed_ops_total" ]
        }
      }
    } ]
  }
  ```
- 使用增删改模式新增转发策略类型的外网访问方式组件配置，如下请求示例配置了基于最后一次生效配置中uid为"1"的访问方式中uid为"1-1"的转发策略配置，修改了监听端口为8080，URL为/test3，域名为test.example.com，URL匹配规则为正则匹配并且剩余字段保持不变后新增到原有配置中。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "access",
      "data" : {
        "spec" : {
          "items" : [ {
            "operator" : "modify",
            "uid" : 1,
            "ports" : [ {
              "operator" : "copy",
              "uid" : "1-1",
              "target_port" : 8080,
              "paths" : [ {
                "path" : "/test3",
                "url_match_mode" : "REGEX",
                "hostname" : "test.example.com"
              } ]
            } ]
          } ]
        }
      }
    } ]
  }
  ```
- 使用增删改模式删除转发策略类型的外网访问方式组件配置，如下请求示例配置了将最后一次生效配置中uid为"1"的访问方式中uid为"1-2"的转发策略配置删除。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "access",
      "data" : {
        "spec" : {
          "items" : [ {
            "operator" : "modify",
            "uid" : 1,
            "ports" : [ {
              "operator" : "delete",
              "uid" : "1-2"
            } ]
          } ]
        }
      }
    } ]
  }
  ```
- 使用增删改模式修改转发策略类型的外网访问方式组件配置，如下请求示例配置了将最后一次生效配置中uid为"1"的访问方式中uid为"1-2"的转发策略配置，只修改监听端口为8081。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "type" : "access",
      "data" : {
        "spec" : {
          "items" : [ {
            "operator" : "modify",
            "uid" : 1,
            "ports" : [ {
              "operator" : "modify",
              "uid" : "1-2",
              "target_port" : 8081
            } ]
          } ]
        }
      }
    } ]
  }
  ```
- 混合策略配置，最大实例数3个，最小1个。
  ```
  POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
  {
    "api_version" : "v1",
    "kind" : "ComponentConfiguration",
    "items" : [ {
      "data" : {
        "spec" : {
          "scale_strategy" : "mix",
          "max_replica_count" : 3,
          "min_replica_count" : 1,
          "triggers" : [ {
            "metadata" : {
              "period_type" : "day",
              "schedulers" : [ {
                "cron" : "00 00 * * *",
                "target_replica" : 1
              }, {
                "cron" : "00 09 * * *",
                "target_replica" : 2
              } ]
            },
            "type" : "cron"
          }, {
            "metadata" : {
              "type" : "Utilization",
              "value" : "80"
            },
            "type" : "cpu"
          }, {
            "metadata" : {
              "type" : "Utilization",
              "value" : "80"
            },
            "type" : "memory"
          } ],
          "switch" : "on"
        }
      },
      "type" : "scaling"
    } ]
  }
  ```
伸缩指标：在cpu使用率、内存使用率阈值都设为80%。
伸缩时间：每天的0点之后保持实例数为1，9点后保持实例数为2。
#### 响应示例
无
#### 状态码
| 状态码 | 描述    |
|:---|:---|
| 200 | 请求成功。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-cae/ErrorCode.html)。
