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, see Obtaining the Project ID and Account ID.

Request

Table 2 describes the request parameters.

Table 2 Parameter description

Parameter

Mandatory

Type

Description

cluster

Yes

Object

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

Table 3 cluster field description

Parameter

Mandatory

Type

Description

instance

Yes

Object

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

datastore

No

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 cluster instances. The value range is 1 to 32.

backupStrategy

No

Object

Whether automatic snapshot creation is enabled. Enabled by default. For details about related parameters, see Table 8. Enabled by default.

httpsEnable

No

Boolean

Whether communication encryption is performed 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.

  • Value true indicates that communication encryption is performed on the cluster.
  • Value false indicates that communication encryption is not performed on the cluster.

authorityEnable

No

Boolean

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.

adminPwd

No

String

Password of the cluster administrator 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.
  • The password must contain at least 3 of the following character types: uppercase letters, lowercase letters, digits, and special characters (~!@#$%^&*()-_=+\\|[{}];:,<.>/?).

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 Enterprise Management Service User Guide.

tags

No

Array of tag objects

Tags in a cluster.

NOTE:

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

Table 4 instance field description

Parameter

Mandatory

Type

Description

flavorRef

Yes

String

Instance flavor name. For example:

  • Value range of flavor ess.spec-2u16g: 40 GB to 1,280 GB
  • Value range of flavor ess.spec-4u32g: 40 GB to 2,560 GB
  • Value range of flavor ess.spec-8u64g: 80 GB to 5,120 GB
  • Value range of flavor ess.spec-16u128g: 160 GB to 10,240 GB

volume

No

Object

If flavorRef is set to a local disk flavor, you do not need to set this parameter. You can obtain the local disk flavor by calling the API for obtaining the instance flavor list. Currently, the following local disk flavors are supported:

  • ess.spec-i3small
  • ess.spec-i3medium
  • ess.spec-i3.8xlarge.8
  • ess.spec-ds.xlarge.8
  • ess.spec-ds.2xlarge.8
  • ess.spec-ds.4xlarge.8

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).

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, which 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. The value can be 5.5.1, 6.2.3, 6.5.4, or 7.1.1. The default value is 5.5.1.

type

No

String

Engine type. The default value is elasticsearch. Currently, the value can only be elasticsearch.

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+08: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

Table 9 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 10 describes the response parameters.

Table 10 Parameter description

Parameter

Type

Description

cluster

Object

Cluster object. For details, see Table 11.

Table 11 cluster field description

Parameter

Type

Description

id

String

Cluster ID

name

String

Cluster name

Examples

Example request

{
    "cluster": {
        "instance": {
            "flavorRef": "ess.spec-ds.xlarge.8",
            "nics": {
                "vpcId": "087a6df3-5459-417d-86b0-cd36830c09ca",
                "netId": "1d5cb532-b506-41c4-b39f-abeb126ba2c1",
                "securityGroupId": "1c021648-ed98-45c2-9a55-70839fc7d779"
            },
            "availability_zone": "cn-north-7b"
        },
        "name": "Es-test",
        "datastore": {
            "version": "6.5.4",
            "type": "elasticsearch"
        },
        "instanceNum": 1,
        "httpsEnable": true,
        "authorityEnable": true,
        "adminPwd": "12334fdsf@"
    }
}
Example response
{
  "cluster": {
    "id": "ef683016-871e-48bc-bf93-74a29d60d214",
    "name": "ES-Test"
  }
}

Status Code

Table 12 describes the status code.

Table 12 Status code

Status Code

Code

Status Code Description

400

BadRequest

Invalid request.

The client should not repeat the request without modifications.

409

Conflict

The request could not 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.