Updated on 2024-12-02 GMT+08:00

Creating a Cluster

Function

This API is used to create a cluster.

Calling Method

For details, see Calling APIs.

URI

POST /v1.0/{project_id}/clusters

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

cluster

Yes

CreateClusterBody object

Cluster.

Table 3 CreateClusterBody

Parameter

Mandatory

Type

Description

instance

Yes

CreateClusterInstanceBody object

Instance.

datastore

Yes

CreateClusterDatastoreBody object

Search engine type.

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

CreateClusterBackupStrategyBody object

Whether to enable automatic snapshot creation. The default setting is disable.

An automatic snapshot creation policy can be enabled only if backupStrategy is not left blank.

httpsEnable

No

Boolean

Whether communication is encrypted on the cluster. The value can be true or 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.
NOTE:

This parameter is supported in clusters 6.5.4 or later.

authorityEnable

No

Boolean

Whether to enable authentication. The value can be true or false. Authentication is disabled by default.

  • true: authentication is enabled for the cluster.
  • false: authentication is disabled for the cluster.
NOTE:

This parameter is supported in clusters 6.5.4 or later.

adminPwd

No

String

Password of the cluster user admin in security mode. This parameter is available only when authorityEnable was set to true during cluster creation.

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

tags

No

Array of CreateClusterTagsBody objects

Cluster tags.

Table 4 CreateClusterInstanceBody

Parameter

Mandatory

Type

Description

flavorRef

Yes

String

Instance flavor. For details about the current instance flavor, see the name attribute in Obtaining the Instance Specifications List.

volume

Yes

CreateClusterInstanceVolumeBody object

Volume information.

nics

Yes

CreateClusterInstanceNicsBody object

Subnet ID.

availability_zone

Yes

String

Availability zone (AZ). You need to specify the AZ name.

By default, a single AZ is specified. If multiple AZs are specified, use commas (,) to separate them. For example, if three AZs are selected in the CN North-Beijing4 region, the value of availability_zone is cn-north-4a,cn-north-4b,cn-north-4c. If a single AZ is used, the value of availability_zone is empty by default.

NOTE:

Note

- If multiple AZs are selected, the name of each AZ must be unique, and the number of nodes must be greater than or equal to 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 CreateClusterInstanceVolumeBody

Parameter

Mandatory

Type

Description

volume_type

Yes

String

Volume type.

  • **COMMON**: common I/O
  • **HIGH**: high I/O
  • **ULTRAHIGH**: ultra-high I/O
  • ESSD: ultra-fast SSD

size

Yes

Integer

Volume size. The value must be greater than 0 and must be a multiple of 4 and 10. For details about the disk size, see the diskrange attribute in Obtaining the Instance Specifications List. Unit: GB.

Table 6 CreateClusterInstanceNicsBody

Parameter

Mandatory

Type

Description

vpcId

Yes

String

VPC ID, which is used for configuring cluster network.

netId

Yes

String

Subnet ID (network ID).

securityGroupId

Yes

String

Security group ID.

Table 7 CreateClusterDatastoreBody

Parameter

Mandatory

Type

Description

version

Yes

String

Elasticsearch engine version. For details, see Supported Cluster Versions.

type

Yes

String

Engine type. The value can be elasticsearch.

Table 8 CreateClusterBackupStrategyBody

Parameter

Mandatory

Type

Description

period

Yes

String

Time when a snapshot is generated every day. Snapshots can only be generated on the hour. The format is HH:mm z: 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.

NOTE:

The default value is 00:00 GMT+08:00. When frequency is set to HOUR, you do not need to specify period. By default, snapshot creation starts from the next hour after the settings are successful.

prefix

Yes

String

Prefix of automatically generated snapshots. It is manually configured. Enter up to 32 characters and start with a lowercase letter. Lowercase letters, numbers, hyphens (-), and underscores (_) are allowed.

keepday

Yes

Integer

Number of snapshots that can be retained. The value ranges from 1 to 90. Expired snapshots will be automatically deleted on the half hour. The deletion policy applies only to automated snapshots that are executed at the same frequency as the current automatic snapshot creation policy.

bucket

No

String

Name of the OBS bucket used for backup.

basePath

No

String

Storage path of the snapshot in the OBS bucket.

agency

No

String

Agency name. You can create an agency to allow CSS to call other cloud services.

NOTE:

If none of the bucket, basePath, and agency parameters are specified, the system will automatically create an OBS bucket and an IAM agency. If the creation fails, you need to manually configure correct parameters.

frequency

No

String

Frequency of automatically creating snapshots.

NOTE:

The default value is DAY. If this parameter is set to HOUR, the scheduled task is executed every hour. If this parameter is set to DAY, the scheduled task is executed every day. If this parameter is set to SUN, MON, TUE, WED, THU, FRI or SAT, the scheduled task is executed at the specified day of every week. For example, SUN indicates that the task is executed once every Sunday. The number of retained snapshots depends on the execution frequency and indexes set in the automatic snapshot creation policy. If the execution interval is short or the index data volume is large, the number of retained automatic snapshots may not reach the preset value. Set this value based on actual conditions.

Table 9 CreateClusterTagsBody

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 1 to 36 characters. Only digits, letters, hyphens (-), and underscores (_) are allowed.

Response Parameters

Status code: 200

Table 10 Response body parameter

Parameter

Type

Description

cluster

CreateClusterClusterResponse object

Cluster. For a pay-per-use cluster, only the **cluster** parameter is returned.

Table 11 CreateClusterClusterResponse

Parameter

Type

Description

id

String

Cluster ID.

name

String

Cluster name.

Example Requests

  • Example request for creating a pay-per-use cluster.
    POST /v1.0/6204a5bd270343b5885144cf9c8c158d/clusters
    
    {
      "cluster" : {
        "instance" : {
          "flavorRef" : "ess.spec-4u16g",
          "volume" : {
            "volume_type" : "COMMON",
            "size" : 120
          },
          "nics" : {
            "vpcId" : "{VPC ID}",
            "netId" : "{NET ID}",
            "securityGroupId" : "{Security group ID}"
          },
          "availability_zone" : "{AZ CODE}"
        },
        "datastore" : {
          "version" : "{cluster-version}",
          "type" : "elasticsearch"
        },
        "name" : "cluster-name",
        "instanceNum" : 3,
        "backupStrategy" : {
          "period" : "16:00 GMT+08:00",
          "prefix" : "snapshot",
          "keepday" : 7,
          "frequency" : "DAY",
          "bucket" : "css-obs-backup",
          "basePath" : "css_repository/obs-path",
          "agency" : "css_obs_agency"
        },
        "httpsEnable" : true,
        "authorityEnable" : true,
        "adminPwd" : "{password}",
        "enterprise_project_id" : "0",
        "tags" : [ {
          "key" : "k1",
          "value" : "v1"
        }, {
          "key" : "k2",
          "value" : "v2"
        } ]
      }
    }

Example Responses

Status code: 200

Request succeeded.

  • Example response for creating a pay-per-use cluster.
    {
      "cluster" : {
        "id" : "ef683016-871e-48bc-bf93-74a29d60d214",
        "name" : "ES-Test"
      }
    }

Status Codes

Status Code

Description

200

Request succeeded.

400

Invalid request.

Modify the request before retry.

409

The request could not be completed due to a conflict with the current state of the resource.

The resource that the client attempts to create already exists, or the update request fails to be processed because of a conflict.

412

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

Error Codes

See Error Codes.