Creating an Application Component Instance
Function
This API is used to create an application component instance.
URI
POST /v2/{project_id}/cas/applications/{application_id}/components/{component_id}/instances
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
project_id |
String |
Yes |
Tenant's project ID. |
application_id |
String |
Yes |
Application ID. |
component_id |
String |
Yes |
Component ID. |
Request
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
name |
String |
Yes |
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 |
String |
Yes |
Environment ID. |
replica |
Integer |
Yes |
Number of instance replicas. |
flavor_id |
String |
Yes |
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 as follows: CUSTOM-xxG:xxC-xxC:xxGi-xxGi. Where:
For example, CUSTOM-10G:0.5C-0.25C: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 |
Map<String, Object> |
Yes |
Artifact. key indicates the component name. In the Docker container scenario, key indicates the container name. See Table 19. |
version |
String |
Yes |
Application component version that meets version semantics. Example: 1.0.0. |
configuration |
Object |
No |
Configuration parameters, such as environment variables, deployment configurations, and O&M monitoring. By default, this parameter is left blank. See Table 3. |
description |
String |
No |
Description. The value can contain up to 128 characters. |
external_accesses |
Array of objects |
No |
External network access. See Table 20. |
refer_resources |
Array of objects |
Yes |
Deployed resources. See Table 21. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
env |
Array of objects |
No |
Environment variable. See Table 4. |
storage |
Array of objects |
No |
Data storage configuration. For details, see Table 5. |
strategy |
Object |
No |
Upgrade policy. For details, see Table 6. |
lifecycle |
Object |
No |
Lifecycle. For details, see Table 7. |
scheduler |
Object |
No |
Scheduling policy. For details, see Table 8. |
probes |
Object |
No |
Health check. For details, see Table 9. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
name |
String |
Yes |
Name of the environment variable. The value contains 1 to 64 characters consisting of letters, digits, underscores (_), hyphens (-), and dots (.), and cannot start with a digit. |
value |
String |
Yes |
Environment variable value. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
type |
String |
Yes |
Storage type. Value:
|
parameters |
Object |
Yes |
Storage parameter. For details, see Table 18. |
mounts |
Array of objects |
Yes |
Directory mounted to the container. For details, see Table 17. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
upgrade |
String |
No |
Upgrade policy. Value: Recreate or RollingUpdate (default). The former indicates in-place upgrade while the latter indicates rolling upgrade. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
entrypoint |
Object |
No |
Startup command. For details, see Table 15. |
post-start |
Object |
No |
Post-start processing. For details, see Table 15. |
pre-stop |
Object |
No |
Pre-stop processing. For details, see Table 15. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
affinity |
Object |
No |
Affinity. For details, see Table 14. |
anti-affinity |
Object |
No |
Anti-affinity. For details, see Table 14. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
livenessProbe |
Object |
No |
Component liveness probe. For details, see Table 10. |
readinessProbe |
Object |
No |
Component service probe. For details, see Table 10. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
type |
String |
Yes |
Value: http, tcp, or command. The check methods are HTTP request check, TCP port check, and command execution check, respectively. |
parameters |
Object |
Yes |
Parameters. |
delay |
Integer |
No |
Interval between the startup and detection. |
timeout |
Integer |
No |
Detection timeout interval. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
scheme |
String |
Yes |
Value: HTTP or HTTPS. |
host |
String |
No |
Pod IP address (default). You can specify an IP address. |
port |
Integer |
Yes |
Port. |
path |
String |
Yes |
Request path. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
command |
Array of String |
Yes |
Command list. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
az |
Array of String |
No |
AZ list. |
node |
Array of String |
No |
Node private IP address list. |
application |
Array of String |
No |
Component instance list. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
command |
Array of String |
Yes |
Command that can be executed. |
args |
Array of String |
Yes |
Running parameters. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
type |
String |
Yes |
Value: command or http. The former indicates command execution and the latter indicates HTTP requests. |
parameters |
Object |
Yes |
Post-start or pre-stop processing parameters. See Table 17. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
command |
Array of String |
Yes |
Command parameters, for example, ["sleep", "1"]. This parameter is applicable to the command type. |
host |
String |
No |
Pod IP address (default). You can also specify an IP address. This parameter is applicable to the http type. |
port |
Integer |
Yes |
Port number. This parameter is applicable to the http type. |
path |
String |
Yes |
Request URL. This parameter is applicable to the http type. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
path |
String |
No |
Host path. This parameter is applicable to the HostPath storage type. |
name |
String |
No |
Name of a configuration item or secret. This parameter is applicable to the ConfigMap and Secret storage type. |
claimName |
String |
No |
PVC name. This parameter is applicable to the PersistentVolumeClaim storage type. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
storage |
String |
Yes |
Storage mode. Value: swr or obs. |
type |
String |
Yes |
Type. Value: package (VM-based deployment) or image (container-based deployment). |
url |
String |
Yes |
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 |
String |
Yes |
Authentication mode. Value: iam or none. Default value: iam. |
version |
String |
No |
Version number. |
properties |
Map<String, Object> |
No |
Property information. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
protocol |
String |
No |
Protocol. Value: http or https. |
address |
String |
No |
Access address. |
forward_port |
Integer |
No |
Port number. |
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
id |
String |
Yes |
Resource ID. Note: If type is set to ecs, the value of this parameter must be Default. |
type |
String |
Yes |
Basic resources: cce, and ecs. Optional resources: dcs, elb, and other services. |
refer_alias |
String |
No |
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 |
Map<String,Object> |
No |
Reference resource parameter.
NOTICE:
|
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
Example request
{ "name": "component-instance-name", "environment_id": "6e763000-9128-4a9d-adea-34c42cc5344d", "flavor_id": "MICRO-5G:0.5C:1G", "replica": 1, "artifacts": { "container-name": { "storage": "swr", "type": "image", "url": "{IP}:20202/xxxxxxxx/junit-platformstest:1.0", "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
Error code must be in the format of SVCSTG.00100.[Error_ID]. Example: SVCSTG.00100400. See Error Codes of Application Management APIs.
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