Adding Component Configuration
Function
This API is used to add component configuration.
URI
POST /v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. See Obtaining a Project ID. |
application_id |
Yes |
String |
Application ID. |
component_id |
Yes |
String |
Component ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token.
Maximum characters: 16,384 |
X-Enterprise-Project-ID |
No |
String |
Enterprise project ID.
For more information about enterprise projects and how to obtain enterprise project IDs, see Enterprise Management User Guide. |
X-Environment-ID |
Yes |
String |
Environment ID.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
api_version |
Yes |
String |
API version. Fixed value: v1. Enumerated value:
|
kind |
Yes |
String |
API type. Fixed value: ComponentConfiguration. Enumerated value:
|
items |
Yes |
Array of ConfigurationItem objects |
Configuration item list. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Component configuration type. Enumerated values:
|
data |
Yes |
ConfigurationData object |
Component configuration data. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
spec |
No |
ConfigurationRequestDataSpec object |
Component configuration data specifications. |
metadata |
No |
ConfigurationDataMetadata object |
Component configuration metadata. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
rds_id |
No |
String |
RDS DB instance ID. This parameter is mandatory when type under ConfigurationItem is set to rds. |
rds_db_name |
No |
String |
RDS database name. This parameter is mandatory when type under ConfigurationItem is set to rds. |
rds_address |
No |
String |
RDS database address. This parameter is mandatory when type under ConfigurationItem is set to rds. |
rds_username |
No |
String |
RDS database username. This parameter is mandatory when type under ConfigurationItem is set to rds. |
rds_password |
No |
String |
RDS database password. This parameter is mandatory when type under ConfigurationItem is set to rds. |
rds_port |
No |
String |
RDS database port. This parameter is mandatory when type under ConfigurationItem is set to rds. |
config_center_addr |
No |
String |
Address of the CSE configuration center. This parameter is mandatory when type under ConfigurationItem is set to cse. |
service_center_addr |
No |
String |
Address for service registry and discovery. This parameter is mandatory when type under ConfigurationItem is set to cse. |
cse_id |
No |
String |
CSE engine ID. This parameter is mandatory when type under ConfigurationItem is set to cse. |
envs |
No |
map<string, object> |
Environment variable. This parameter is mandatory when type under ConfigurationItem is set to env. Common environment variables:
|
ip |
No |
String |
EIP, which is returned when no domain name is configured. |
items |
No |
Array of AccessConfigurationDataItems objects |
Access configuration list. This parameter is mandatory when type under ConfigurationItem is set to access. |
scale_strategy |
No |
String |
AS policy type. This parameter is mandatory when type under ConfigurationItem is set to scaling. Enumerated values:
|
max_replica_count |
No |
Integer |
Maximum number of instances that can be scaled in an AS policy. This parameter is mandatory when type under ConfigurationItem is set to scaling. |
min_replica_count |
No |
Integer |
Minimum number of instances that can be scaled in an AS policy. This parameter is mandatory when type under ConfigurationItem is set to scaling. |
advanced |
No |
Advanced settings of an AS policy. This parameter is mandatory when type under ConfigurationItem is set to scaling. |
|
triggers |
No |
Array of ScaleConfigurationDataTrigger objects |
Trigger list of an AS policy. This parameter is mandatory when type under ConfigurationItem is set to scaling. |
volumes |
No |
Array of VolumeConfigurationDataVolume objects |
Cloud storage configuration list. This parameter is mandatory when type under ConfigurationItem is set to volume. |
livenessProbe |
No |
Liveness probe configuration for health check. This parameter is mandatory when type under ConfigurationItem is set to healthCheck. |
|
startupProbe |
No |
Startup probe configuration for health check. This parameter is mandatory when type under ConfigurationItem is set to healthCheck. |
|
readinessProbe |
No |
Readiness probe configuration for health check. This parameter is mandatory when type under ConfigurationItem is set to healthCheck. |
|
postStart |
No |
postStart object |
Post-startup processing configured for lifecycle management. This parameter is mandatory when type under ConfigurationItem is set to lifecycle. |
preStop |
No |
preStop object |
Pre-stop processing configured for lifecycle management. This parameter is mandatory when type under ConfigurationItem is set to lifecycle. |
log_paths |
No |
Array of strings |
Custom log path array. This parameter is mandatory when type under ConfigurationItem is set to log. |
instrumentation |
No |
String |
Agent injection mode. This parameter is mandatory when type under ConfigurationItem is set to apm2. |
path |
No |
String |
Collection path for custom metric monitoring. This parameter is mandatory when type under ConfigurationItem is set to customMetric. |
port |
No |
String |
Collection port for custom metric monitoring. This parameter is mandatory when type under ConfigurationItem is set to customMetric. |
metrics |
No |
Array of strings |
Metric for custom monitoring. This parameter is mandatory when type under ConfigurationItem is set to customMetric. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Access mode. Enumerated values:
|
domain_names |
No |
String |
Domain name for private network access. |
access_control |
No |
AccessControl object |
Access control configuration. Blacklists and whitelists can be configured. |
ports |
No |
Array of AccessConfigurationPort objects |
Access information, such as the port, protocol, certificate, and URL. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
black |
No |
Array of strings |
Blacklist array.
|
white |
No |
Array of strings |
Whitelist array.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
target_port |
No |
Integer |
Listening port. |
port |
No |
Integer |
Access port. |
protocol |
No |
String |
Protocol. Load balancing supports TCP, HTTP, and HTTPS while route configuration supports HTTP and HTTPS. Enumerated values:
|
default_certificate |
No |
String |
Default certificate, which is configured when the access mode is set to Ingress and protocol is set to HTTPS. It will be used if SNI is not configured. |
certificate |
No |
String |
Certificate. |
policy |
No |
String |
Security policy. Enumerated values:
|
paths |
No |
Array of AccessConfigurationHttpPath objects |
Path and domain name for matching. |
elb_id |
No |
String |
Selected ELB ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
hostname |
No |
String |
Domain name. If it is left blank, the IP address is used. |
path |
No |
String |
URL. |
url_match_mode |
No |
String |
URL path matching mode. Options: STARTS_WITH, REGEX, and EQUAL_TO. Enumerated values:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
scaledown_stabilization_seconds |
No |
Integer |
Cooling time window for scale-in. |
scaledown_rate |
No |
Integer |
Scale-in step. |
scaleup_stabilization_seconds |
No |
Integer |
Cooling time window for scale-out. |
scaleup_rate |
No |
Integer |
Scale-out step. |
disable_scaledown |
No |
Boolean |
Whether to disable automatic scale-in. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Metric type. Enumerated values:
|
metadata |
No |
ScalingTriggerMeta object |
Metadata. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Data type, which can only be Utilization. This parameter is mandatory when type under ScaleConfigurationDataTrigger is set to cpu or memory. |
value |
No |
String |
Threshold for triggering scaling. This parameter is mandatory when type under ScaleConfigurationDataTrigger is set to cpu or memory. |
period_type |
No |
String |
Validity period. This parameter is mandatory when type under ScaleConfigurationDataTrigger is set to cron. Enumerated values:
|
schedulers |
No |
Array of CronTriggerScheduler objects |
Time when the scaling is triggered and number of instances triggered in each period. This parameter is mandatory when type under ScaleConfigurationDataTrigger is set to cron. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
cron |
No |
String |
Trigger time, which is a cron expression consisting of five fields. |
target_replica |
No |
Integer |
Number of required instances. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
volume_id |
No |
String |
Cloud storage ID. |
resource_name |
No |
String |
Cloud storage name. |
resource_type |
No |
String |
Resource type. Enumerated values:
|
resource_sub_type |
No |
String |
Resource sub-type. Enumerated values:
|
umask |
No |
String |
Default permission on a directory or file. SFS 3.0 cloud storage does not support this parameter. Default value: 0027. |
mount_info |
No |
Array of VolumeConfigurationMountInfo objects |
Cloud storage mounting information. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
path |
No |
String |
Container mount path. |
sub_path |
No |
String |
Sub-path. |
access_mode |
No |
String |
Read or write permission. Enumerated values:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
periodSeconds |
No |
Integer |
Detection period. Unit: second. |
initialDelaySeconds |
No |
Integer |
Latency. Unit: second. |
timeoutSeconds |
No |
Integer |
Timeout. Unit: second. |
successThreshold |
No |
Integer |
Success threshold. |
failureThreshold |
No |
Integer |
Failure threshold. |
httpGet |
No |
HTTP request check information in the health check configuration. |
|
tcpSocket |
No |
TCP port check information in the health check configuration. |
|
exec |
No |
HealthCheckConfigurationExec object |
Command check information in the health check configuration. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
periodSeconds |
No |
Integer |
Detection period. Unit: second. |
initialDelaySeconds |
No |
Integer |
Latency. Unit: second. |
timeoutSeconds |
No |
Integer |
Timeout. Unit: second. |
successThreshold |
No |
Integer |
Success threshold. |
failureThreshold |
No |
Integer |
Failure threshold. |
httpGet |
No |
HTTP request check information in the health check configuration. |
|
tcpSocket |
No |
TCP port check information in the health check configuration. |
|
exec |
No |
HealthCheckConfigurationExec object |
Command check information in the health check configuration. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
periodSeconds |
No |
Integer |
Detection period. Unit: second. |
initialDelaySeconds |
No |
Integer |
Latency. Unit: second. |
timeoutSeconds |
No |
Integer |
Timeout. Unit: second. |
successThreshold |
No |
Integer |
Success threshold. |
failureThreshold |
No |
Integer |
Failure threshold. |
httpGet |
No |
HTTP request check information in the health check configuration. |
|
tcpSocket |
No |
TCP port check information in the health check configuration. |
|
exec |
No |
HealthCheckConfigurationExec object |
Command check information in the health check configuration. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
path |
No |
String |
URL. |
port |
No |
String |
Port. |
scheme |
No |
String |
Protocol. Enumerated values:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
port |
No |
String |
Port. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
command |
No |
Array of strings |
Shell statement. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
exec |
No |
LifeCycleConfigurationExec object |
Command to execute. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
exec |
No |
LifeCycleConfigurationExec object |
Command to execute. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
command |
No |
Array of strings |
Shell statement. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
annotations |
No |
Map<String,String> |
Additional parameters. Assume that you need to use the weighted round robin algorithm for load balancing and disable health check. Configuration example:
|
Response Parameters
None
Example Request
- Configure an RDS database: Set the database name to cae, address to 100.xx.xx.xxx, and port number to 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" } } } ] }
- Configure CSE addresses: Set the configuration center addresses to https://192.168.1.xxx:30103,https://192.168.1.xxx:30103, and the service registration and discovery addresses to 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" } } } ] }
- Create an environment variable component configuration: Set the time zone to Asia/Shanghai, and inject a secret named password as the environment variable.
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" : "db_password", "value_from" : { "name" : "password", "reference_type" : "dewSecret" } } } } } ] }
- Configure private and public network access:
- Set the private network access mode to ClusterIP, listening port number to 80, access port number to 8080, and protocol to TCP.
- Set the public network access mode to LoadBalancer, listening port number to 80, access port number to 9090, and protocol to TCP. Configure a whitelist to allow access from 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" } ] } ] } } } ] }
- Configure two forwarding policies for public network access: Set the protocol to HTTPS, retain the default load balancing policy (weighted round robin algorithm), set the access port number to 8443, configure a blacklist to deny access from 10.120.1.1 and 10.120.1.2, set the security policy to tls-1-2-strict, and retain the default server certificate test.
- For the first forwarding policy, set the domain name to test.example.com, URL match mode to STARTS_WITH, path to /test1, and listening port number to 80, and use the default certificate test.
- For the second forwarding policy, set the domain name to test.example.cn, URL match mode to STARTS_WITH, path to /test2, listening port number to 80, and certificate to 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" } } } } ] }
- Create an AS policy: Set max_replica_count to 3, min_replica_count to 1, CPU usage to 30%, memory usage to 30%, and scaledown_stabilization_seconds to 300 (5 minutes), scaledown_rate to 99, scaleup_rate to 4, and disable_scaledown to false.
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" } ] } } } ] }
- Configure cloud storage (OBS bucket or OBS parallel file system): For an object bucket, set the mount path to /tmp and permission to ReadWriteMany. For a parallel file system, set the mount path to /temp and permission to ReadWriteMany.
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" } ] } } } ] }
- Configure health check, including configuring a liveness probe, readiness probe, and startup probe.
- Configure a liveness probe: Set the type to livenessProbe, detection period to 10s, latency to 1s, timeout to 1s, success threshold to 1, failure threshold to 3, port number to 80, and protocol to HTTP. Leave the path and request header blank.
- Configure a readiness probe: Set the type to readinessProbe, detection period to 10s, latency to 0s (if the value is 0, it is optional to transfer this parameter), timeout to 1s, success threshold to 1, failure threshold to 3, port number to 80, and protocol to HTTP. Leave the path and request header blank.
- Configure a startup probe: Set the type to startupProbe, detection period to 10s, latency to 0s (if the value is 0, it is optional to transfer this parameter), timeout to 1s, success threshold to 1, failure threshold to 3, port number to 80, protocol to HTTP, and request header to x-auth-token. Leave the path blank.
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" } } } } } ] }
- Configure lifecycle management (such as post-startup and pre-stop processing). Configure the post-startup command /bin/sh -c "echo service start" and the pre-stop command /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" ] } } } } } ] }
- Configure custom log collection: Specify path /var/log/error.log to collect logs.
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" ] } } } ] }
- Configure performance management: Set instrumentation to automatic.
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" } } } ] }
- Configure custom metric monitoring: Set the collection path to /metrics and port to 2112, and specify custom metric 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" ] } } } ] }
Example Response
None
Status Code
Status Code |
Description |
---|---|
200 |
The request is successful. |
Error Code
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot