Creating an Application Component Instance
Function
This API is used to create a component instance.
URI
POST /v2/{project_id}/cas/applications/{application_id}/components/{component_id}/instances
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Tenant's project ID. See Obtaining a Project ID. |
application_id |
Yes |
String |
Application ID. See Obtaining All Applications. |
component_id |
Yes |
String |
Component ID. See Obtaining All Components of an Application. |
Request
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Message body type (format). Default value: application/json;charset=utf8. |
X-Auth-Token |
Yes |
String |
API calling can be authenticated using a token or AK/SK. If you use a token, this parameter is mandatory and must be set to the token. For details about how to obtain a token, see Obtaining a User Token. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Component instance name. The value contains 2 to 63 characters consisting of lowercase letters, digits, and hyphens (-). It starts with a lowercase letter and ends with a lowercase letter or digit. |
environment_id |
Yes |
String |
Environment ID. |
replica |
Yes |
Integer |
Number of instance replicas. |
flavor_id |
Yes |
String |
Resource specifications, which can be obtained by using the API in Obtaining All Supported Flavors of Application Resources. If you need to customize resource specifications, the format is CUSTOM-xxG:xxm-xxm:xxGi-xxGi. Where:
For example, CUSTOM-10G:0.5m-0.25m:1.6Gi-0.8Gi indicates that the maximum number of CPU cores allocated to a component instance is 0.5, the minimum number of CPU cores is 0.25, the maximum memory is 1.6 Gi, and the minimum memory is 0.8 Gi. |
artifacts |
Yes |
Map<String, Object> |
Artifact. key indicates the component name. In the Docker container scenario, key indicates the container name. See Table 21. If the source parameters of a component specify the software package source, this parameter is optional, and the software package source of the component is inherited by default. Otherwise, this parameter is mandatory. |
version |
Yes |
String |
Application component version that meets version semantics. Example: 1.0.0. |
configuration |
No |
Object |
Configuration parameters, such as environment variables, deployment configurations, and O&M monitoring. By default, this parameter is left blank. See Table 4. |
description |
No |
String |
Description. The value can contain up to 128 characters. |
external_accesses |
No |
Array of objects |
External network access. See Table 22. |
refer_resources |
Yes |
Array of objects |
Deployed resources. See Table 23. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
env |
No |
Array of objects |
Environment variable. See Table 5. |
storage |
No |
Array of objects |
Data storage configuration. See Table 6. |
strategy |
No |
Object |
Upgrade strategy. See Table 7. |
lifecycle |
No |
Object |
Lifecycle. See Table 8. |
scheduler |
No |
Object |
Scheduling strategy. See Table 9. |
probes |
No |
Object |
Health check. See Table 10. |
container_spec |
No |
Object |
Container information. See Table 24. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Environment variable name. The value contains 1 to 64 characters, including letters, digits, underscores (_), hyphens (-), and dots (.), and cannot start with a digit. |
value |
Yes |
String |
Environment variable value. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Storage type. Value:
|
parameters |
Yes |
Object |
Storage parameter. See Table 19. |
mounts |
Yes |
Array of objects |
Directory mounted to the container. See Table 20. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
upgrade |
No |
String |
Upgrade policy. Value: Recreate or RollingUpdate (default). The former indicates in-place upgrade while the latter indicates rolling upgrade. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
entrypoint |
No |
Object |
Startup command. See Table 16. |
post-start |
No |
Object |
Post-start processing. See Table 17. |
pre-stop |
No |
Object |
Pre-stop processing. See Table 17. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
affinity |
No |
Object |
Affinity. See Table 15. |
anti-affinity |
No |
Object |
Anti-affinity. See Table 15. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
livenessProbe |
No |
Object |
Component liveness probe. See Table 11. |
readinessProbe |
No |
Object |
Component service probe. See Table 11. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Value: http, tcp, or command. The check methods are HTTP request check, TCP port check, and command execution check, respectively. |
parameters |
Yes |
Object |
Parameters. |
delay |
No |
Integer |
Interval between the startup and detection. |
timeout |
No |
Integer |
Detection timeout interval. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
scheme |
No |
String |
Value: HTTP or HTTPS. |
host |
No |
String |
Pod IP address (default). You can specify an IP address. |
port |
No |
Integer |
Port. |
path |
No |
String |
Request path. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
command |
No |
Array of String |
Command list. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
az |
No |
Array of String |
AZ list. |
node |
No |
Array of String |
Node private IP address list. |
application |
No |
Array of String |
Component instance list. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
command |
No |
Array of String |
Command that can be executed. |
args |
No |
Array of String |
Running parameters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Value: command or http. The former indicates command execution and the latter indicates HTTP requests. |
parameters |
No |
Object |
Post-start or pre-stop processing parameters. See Table 18. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
command |
No |
Array of String |
Command parameters, for example, ["sleep", "1"]. This parameter is applicable to the command type. |
host |
No |
String |
Pod IP address (default). You can also specify an IP address. This parameter is applicable to the http type. |
port |
No |
Integer |
Port number. This parameter is applicable to the http type. |
path |
No |
String |
Request URL. This parameter is applicable to the http type. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
path |
No |
String |
Host path. This parameter is applicable to the HostPath storage type. |
name |
No |
String |
Name of a configuration item or secret. This parameter is applicable to the ConfigMap and Secret storage type. |
defaultMode |
No |
Integer |
Mounting permission. The value is in decimal format. Example: 384. |
medium |
No |
String |
This parameter is applicable to EmptyDir storage. If it is not specified, the default disk medium is used. If it is set to memory, memory storage is enabled. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
path |
Yes |
String |
Path of the mounted disk. |
subPath |
No |
String |
Sub-path of the mounted disk. |
readOnly |
Yes |
boolean |
Permission of the mounted disk, which can be read-only or read/write. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
storage |
Yes |
String |
Storage mode. Value: swr (software repository), swr (image), obs, or codearts. |
type |
Yes |
String |
Type.
|
url |
Yes |
String |
Software package or image address. For a component deployed on a VM, this parameter is the software package address. For a component deployed based on a container, this parameter is the image address or component name:v${index}. The latter indicates that the component source code or the image automatically built using the software package will be used. |
auth |
Yes |
String |
Authentication mode. Value: iam or none. Default value: iam. |
version |
No |
String |
Version number. |
properties |
No |
Map<String, Object> |
Property information. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
protocol |
Yes |
String |
Protocol. Value: http or https. |
address |
Yes |
String |
Access address. |
forward_port |
Yes |
Integer |
Port number. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
Yes |
String |
Resource ID. If type is set to ecs, the value of this parameter must be Default. |
type |
Yes |
String |
Basic resources: cce, as, and ecs. Optional resources: rds, dcs, elb, cse, and other services. |
refer_alias |
No |
String |
Application alias, which is provided only in DCS scenario. Value: "distributed_session", "distributed_cache", "distributed_session, distributed_cache". Default value: "distributed_session, distributed_cache". |
parameters |
No |
Map<String, Object> |
Reference resource parameter.
NOTICE:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
containers |
No |
Array of objects |
Container information. See Table 25. |
type |
No |
String |
Workload type.
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Container name. |
size |
No |
Object |
Container size. See Table 26. |
env |
No |
Array of objects |
Environment variable. See Table 5. |
storage |
No |
Array of objects |
Data storage configuration. See Table 6. |
lifecycle |
No |
Object |
Lifecycle. See Table 8. |
probes |
No |
Object |
Health check. See Table 10. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
No |
String |
Resource specifications, which can be obtained by using the API in Obtaining All Supported Flavors of Application Resources. If you need to customize resource specifications, the format is CUSTOM-xxG:xxm-xxm:xxGi-xxGi. Where:
For example, CUSTOM-10G:0.5m-0.25m:1.6Gi-0.8Gi indicates that the maximum number of CPU cores allocated to a component instance is 0.5, the minimum number of CPU cores is 0.25, the maximum memory is 1.6 Gi, and the minimum memory is 0.8 Gi. |
Response
Parameter |
Type |
Description |
---|---|---|
job_id |
String |
Job ID, which is used to query information about the created job. |
instance_id |
String |
Component instance ID. |
Example Request
Create component instance component-instance-name. Select the environment whose ID is 6e763000-9128-4a9d-adea-34c42cc5344d as the running environment. Select the demo.jar package in the myapp bucket of OBS as the deployment component. Select the CCE resource whose ID is b6862a62-d916-11e9-bdf1-0255ac101fd9 and the ELB resource whose ID is 8c0a45cc-626f-4d65-8257-507ee059aa9a as the deployment resources.
{ "name": "component-instance-name", "environment_id": "6e763000-9128-4a9d-adea-34c42cc5344d", "flavor_id": "MICRO-5G:0.5m:1G", "replica": 1, "artifacts": { "container-name": { "storage": "obs", "type": "package", "url": "obs://myapp/demo.jar", "properties": { "bucket": "myapp", "key": "demo.jar", "endpoint": "https://obs.region_id.external_domain_name.com" }, "auth": "iam" } }, "version": 1, "description": "instance desc", "configuration": { "env": [ { "name": "log-level", "value": "warn" } ] }, "refer_resources": [ { "id": "b6862a62-d916-11e9-bdf1-0255ac101fd9", "type": "cce", "parameters": { "namespace": "default" } }, { "id": "8c0a45cc-626f-4d65-8257-507ee059aa9a", "type": "elb" } ] }
Example Response
{ "instance_id": "89f5baf5-efe4-4f12-9c0d-734d2af5a184", "job_id": "JOB66761060-f209-407c-a093-4df6f531b9dc" }
Status Code
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
404 |
Not Found |
500 |
Internal Server Error |
Error Code
The error code format is SVCSTG.00100.[Error_ID], for example, SVCSTG.00100400. For details, see ServiceStage 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