Creating a Cluster

Function

This API is used to create a cluster.

URI

POST /v1.0/{project_id}/clusters
Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID and Name.

Request

Table 2 describes the request parameters.

Table 2 Parameter description

Parameter

Mandatory

Type

Description

cluster

Yes

Object

Cluster. For details about related parameters, see Table 3.

Table 3 cluster field description

Parameter

Mandatory

Type

Description

instance

Yes

Object

Instance. For details about related parameters, see Table 4.

datastore

Yes

Object

Type of the data search engine. For details about related parameters, see Table 7.

name

Yes

String

Cluster name. It contains 4 to 32 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed. The value must start with a letter.

instanceNum

Yes

Integer

Number of clusters. The value range is 1 to 32.

backupStrategy

No

Object

Automatic snapshot creation. This function is disabled by default. For details about related parameters, see Table 8.

Note

The automatic snapshot creation policy is enabled only if this parameter is specified.

diskEncryption

Yes

Object

Indicates whether disks are encrypted. For details about related parameters, see Table 9.

httpsEnable

No

String

Indicates whether communication is encrypted on the cluster. Available values include true and false. By default, communication encryption is disabled. When httpsEnable is set to true, authorityEnable must be set to true.

  • true: communication is encrypted on the cluster.

  • false: communication is not encrypted on the cluster.

authorityEnable

No

Boolean

Indicates whether to enable authentication. Available values include true and false. Authentication is disabled by default. When authentication is enabled, httpsEnable must be set to true.

  • Value true indicates that authentication is enabled for the cluster.

  • Value false indicates that authentication is disabled for the cluster.

    Note

    This parameter is supported in clusters 7.1.1 or later.

adminPwd

No

String

Password of the cluster user admin in security mode. This parameter is mandatory only when authorityEnable is set to true.

Note

  • The administrator password must meet the following requirements:

    • The password can contain 8 to 32 characters.

    • Passwords must contain at least 3 of the following character types: uppercase letters, lowercase letters, numbers, and special characters (~!@#$%^&*()-_=+\\|[{}];:,<.>/?).

  • Weak password verification is required for a security cluster. You are advised to set a strong password.

enterprise_project_id

No

String

Enterprise project ID. When creating a cluster, associate the enterprise project ID with the cluster. The value can contain a maximum of 36 characters. It is string 0 or in UUID format with hyphens (-). Value 0 indicates the default enterprise project.

Note

For details about how to obtain enterprise project IDs and features, see the .

tags

No

Array of tag objects

Tags in a cluster.

Note

For details about the tag feature, see the Tag Management Service.

Table 4 instance field description

Parameter

Mandatory

Type

Description

flavorRef

Yes

String

Instance flavor name. For example:

  • Value range of flavor css.medium.8: 40 GB to 640 GB

  • Value range of flavor css.xlarge.8: 40 GB to 2,560 GB

  • Value range of flavor css.2xlarge.8: 80 GB to 5,120 GB

  • Value range of flavor css.4xlarge.8: 160 GB to 10,240 GB

  • Value range of flavor css.xlarge.4: 40 GB to 1,600 GB

  • Value range of flavor css.2xlarge.4: 80 GB to 3,200 GB

  • Value range of flavor css.4xlarge.4: 100 GB to 6,400 GB

  • Value range of flavor css.8xlarge.4: 160 GB to 10,240 GB

  • Value range of flavor css.xlarge.2: 40 GB to 800 GB

  • Value range of flavor css.2xlarge.2: 80 GB to 1,600 GB

  • Value range of flavor css.4xlarge.2: 100 GB to 3,200 GB

  • Value range of flavor css.8xlarge.2: 320 GB to 10,240 GB

volume

Yes

Object

Information about the volume. For details about related parameters, see Table 5.

nics

Yes

Object

Subnet information. For details about related parameters, see Table 6.

availability_zone

No

String

Availability zone (AZ). A single AZ is created when this parameter is not specified.

Separate multiple AZs with commas (,), for example, az1,az2. AZs must be unique and ensure that the number of nodes be at least the number of AZs.

If the number of nodes is a multiple of the number of AZs, the nodes are evenly distributed to each AZ. If the number of nodes is not a multiple of the number of AZs, the absolute difference between node quantity in any two AZs is 1 at most.

Table 5 volume field description

Parameter

Mandatory

Type

Description

volume_type

Yes

String

COMMON: Common I/O

HIGH: High I/O

ULTRAHIGH: Ultra-high I/O

size

Yes

Integer

Volume size. The minimum value is 40. The value must be a multiple of 4 and 10.

Unit: GB

Table 6 nics field description

Parameter

Mandatory

Type

Description

vpcId

Yes

String

VPC ID, which is used for configuring cluster network.

netId

Yes

String

Subnet ID. All instances in a cluster must have the same subnets and security groups.

securityGroupId

Yes

String

Security group ID. All instances in a cluster must have the same subnets and security groups.

Table 7 datastore field description

Parameter

Mandatory

Type

Description

version

Yes

String

Engine version. For details about the supported versions, see Supported Cluster Versions.

type

Yes

String

Engine type. Elasticsearch and OpenSearch are supported.

Table 8 backupStrategy field description

Parameter

Mandatory

Type

Description

period

Yes

String

Time when a snapshot is created every day. Snapshots can only be created on the hour. The time format is the time followed by the time zone, specifically, HH:mm z. In the format, HH:mm refers to the hour time and z refers to the time zone, for example, 00:00 GMT+08:00 and 01:00 GMT+02:00.

prefix

Yes

String

Prefix of the name of the snapshot that is automatically created.

keepday

Yes

Integer

Number of days for which automatically created snapshots are reserved.

Value range: 1 to 90

bucket

No

String

OBS bucket used for storing backup. If there is snapshot data in an OBS bucket, only the OBS bucket will be used for backup storage and cannot be changed.

basePath

No

String

Storage path of the snapshot in the OBS bucket.

agency

No

String

IAM agency used to access OBS.

Note

If none of the bucket, basePath, and agency parameters are specified, the system will automatically create an OBS bucket and an IAM agency.

Table 9 diskEncryption field description

Parameter

Mandatory

Type

Description

systemEncrypted

Yes

String

Value 1 indicates encryption is performed, and value 0 indicates encryption is not performed.

systemCmkid

Yes

String

Key ID.

  • The Default Master Keys cannot be used to create grants. Specifically, you cannot use Default Master Keys whose aliases end with /default in KMS to create clusters.

  • After a cluster is created, do not delete the key used by the cluster. Otherwise, the cluster will become unavailable.

Table 10 tags field description

Parameter

Mandatory

Type

Description

key

Yes

String

Tag key. The value can contain 1 to 36 characters. Only digits, letters, hyphens (-) and underscores (_) are allowed.

value

Yes

String

Tag value. The value can contain 0 to 43 characters. Only digits, letters, hyphens (-) and underscores (_) are allowed.

Response

Table 11 describes the response parameters.

Table 11 Parameter description

Parameter

Type

Description

cluster

Object

Cluster. For details, see Table 12.

Table 12 cluster field description

Parameter

Type

Description

id

String

Cluster ID.

name

String

Cluster name

Examples

Example request

POST /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters
{
    "cluster": {
        "name": "ES-Test",
        "instanceNum": 4,
        "instance": {
            "availability_zone": "eu-du-01",
            "flavorRef": "css.large.8",
            "volume": {
                "volume_type": "COMMON",
                "size": 100
            },
            "nics": {
                "vpcId": "fccd753c-91c3-40e2-852f-5ddf76d1a1b2",
                "netId": "af1c65ae-c494-4e24-acd8-81d6b355c9f1",
                "securityGroupId": "7e3fed21-1a44-4101-ab29-34e57124f614"
            }
        },
        "httpsEnable": "false",
        "diskEncryption": {
            "systemEncrypted": "1",
            "systemCmkid": "42546bb1-8025-4ad1-868f-600729c341ae"
        }
    }
}

Example response

{
  "cluster": {
    "id": "ef683016-871e-48bc-bf93-74a29d60d214",
    "name": "ES-Test"
  }
}

Status Code

Table 13 describes the status code.

Table 13 Status code

Status Code

Code

Status Code Description

400

BadRequest

Invalid request.

Modify the request instead of retrying.

409

Conflict

The request cannot be processed due to a conflict.

This status code indicates that the resource that the client attempts to create already exits, or the request fails to be processed because of the update of the conflict request.

412

Precondition Failed

The server does not meet one of the preconditions that the requester puts on the request.

200

OK

The request is processed successfully.