หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating an Application Component Instance

Updated on 2024-10-16 GMT+08:00

Function

This API is used to create a component instance.

URI

POST /v2/{project_id}/cas/applications/{application_id}/components/{component_id}/instances

Table 1 Path parameters

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

Table 2 Request header parameters

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.

Table 3 Request body parameters

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:

  • xxG: storage capacity allocated to a component instance. It is a reserved field. You can set it to a fixed number.
  • xxm-xxm: the maximum and minimum number of CPU cores allocated to a component instance.
  • xxGi-xxGi: the maximum and minimum memory allocated to a component instance.

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.

Table 4 configuration

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.

Table 5 environment

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.

Table 6 storage

Parameter

Mandatory

Type

Description

type

Yes

String

Storage type. Value:

  • HostPath: host path mounting.
  • EmptyDir: temporary directory mounting.
  • ConfigMap: configuration item mounting.
  • Secret: secret volume mounting.
  • PersistentVolumeClaim: cloud storage mounting.

parameters

Yes

Object

Storage parameter. See Table 19.

mounts

Yes

Array of objects

Directory mounted to the container. See Table 20.

Table 7 strategy

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.

Table 8 lifecycle

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.

Table 9 scheduler

Parameter

Mandatory

Type

Description

affinity

No

Object

Affinity. See Table 15.

anti-affinity

No

Object

Anti-affinity. See Table 15.

Table 10 probes

Parameter

Mandatory

Type

Description

livenessProbe

No

Object

Component liveness probe. See Table 11.

readinessProbe

No

Object

Component service probe. See Table 11.

Table 11 probes_object

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.

Table 12 probes_param_http

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.

Table 13 probes_param_command

Parameter

Mandatory

Type

Description

command

No

Array of String

Command list.

Table 14 probes_param_tcp

Parameter

Mandatory

Type

Description

port

No

Integer

Port

Table 15 scheduler_affinity

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.

Table 16 lifecycle_entrypoint

Parameter

Mandatory

Type

Description

command

No

Array of String

Command that can be executed.

args

No

Array of String

Running parameters.

Table 17 lifecycle_process

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.

Table 18 lifecycle_process_parameters

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.

Table 19 storage_parameters

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.

Table 20 storage_mounts

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.

Table 21 artifact

Parameter

Mandatory

Type

Description

storage

Yes

String

Storage mode. Value: swr (software repository), swr (image), obs, or codearts.

type

Yes

String

Type.

  • VM-based deployment supports package.
  • Container-based deployment supports package and image.

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.

Table 22 external_accesses

Parameter

Mandatory

Type

Description

protocol

Yes

String

Protocol. Value: http or https.

address

Yes

String

Access address.

forward_port

Yes

Integer

Port number.

Table 23 refer_resources

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:
  • When type is set to cce, this parameter is mandatory. You need to specify the namespace of the cluster where the component is to be deployed. Example: {"namespace": "default"}.
  • When type is set to ecs, this parameter is mandatory. You need to specify the hosts where the component is to be deployed. Example: {"hosts":["04d9f887-9860-4029-91d1-7d3102903a69", "04d9f887-9860-4029-91d1-7d3102903a70"]}}.
Table 24 container_spec

Parameter

Mandatory

Type

Description

containers

No

Array of objects

Container information. See Table 25.

type

No

String

Workload type.

  • deployment
  • statefulset
Table 25 container

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.

Table 26 size

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:

  • xxG: storage capacity allocated to a component instance. It is a reserved field. You can set it to a fixed number.
  • xxm-xxm: the maximum and minimum number of CPU cores allocated to a component instance.
  • xxGi-xxGi: the maximum and minimum memory allocated to a component instance.

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

Table 27 Response parameters

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

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback