Help Center > > API Reference> APIs> Cluster Management> Creating a Node

Creating a Node

Updated at: Aug 13, 2019 GMT+08:00

Function

This API is used to create a node in a specified cluster.

URI

POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes

Table 1 describes the parameters of the API.

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Project ID. For details about how to obtain the project ID, see How to Obtain Parameters in the API URI.

cluster_id

Yes

Cluster ID. For details about how to obtain the cluster ID, see How to Obtain Parameters in the API URI.

Request

Request parameters:

Table 2 and Table 3 describe the request parameters.

Table 2 Parameters in the request header

Parameter

Mandatory

Description

Content-Type

Yes

Message body type (format). Possible values:

  • application/json;charset=utf-8
  • application/json

X-Auth-Token

Yes

Requests for calling a HUAWEI CLOUD API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details on how to obtain a user token, see Token-based Authentication.

Table 3 Parameters in the request body

Parameter

Mandatory

Type

Description

kind

Yes

String

API type. The value is fixed at Node and cannot be changed.

apiVersion

Yes

String

API version. The value is fixed at v3 and cannot be changed.

metadata

Yes

Table 4

Node's metadata, which is a collection of attributes. Empty metadata (metadata without containing any attributes) is not allowed.

spec

Yes

Table 5

Detailed description of the node targeted by this API. CCE creates or updates objects by defining or updating its spec.

Table 4 Data structure of the metadata field

Parameter

Mandatory

Type

Description

name

No

String

Node name.

NOTE:

Enter 4 to 32 characters starting with a letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed.

labels

No

Map[string]string

Node labels in the format of key-value pairs.

Labels are used to select objects that meet certain criteria.

Example:

"labels": {
  "key" : "value"
}

annotations

No

Map[string]string

Node annotations in the format of key-value pairs.

"annotations": {
  "key1" : "value1",
  "key2" : "value2"
}
NOTE:

Annotations are not used to identify or select objects. The metadata in Annotations may be small or large, structured or unstructured, and may include characters that are not allowed in labels.

Table 5 Data structure of the spec field

Parameter

Mandatory

Type

Description

flavor

Yes

String

Node flavor. For details, see the description of the flavorRef parameter in the API that is used to create an ECS.

az

Yes

String

Name of the availability zone where the node is located. For details, see the description of the availability_zone parameter in the API that is used to create an ECS.

os

No

String

Node OS. Possible values:

  • EulerOS 2.2
  • CentOS 7.4

login

Yes

Table 6

Node login mode, which can be key pair or password.

rootVolume

Yes

Table 8

System disk parameters of the node.

dataVolumes

Yes

Table 8

Data disk parameters of the node. Currently, only one data disk can be configured per node.

publicIP

No

Table 9

EIP used by the node to access public networks.

billingMode

No

Integer

Node billing mode.

  • Value 0 indicates pay-per-use. Value 2 indicates yearly/monthly billing.
NOTICE:

Currently, this API can add yearly/monthly billed nodes only to BMS clusters of v1.9.7-r1 and later.

Tokens of common users can be used to create yearly/monthly billed nodes.

count

Yes

Integer

Quantity of nodes to be created at a time. The value must be a positive integer ranging from 1 to the maximum node limit. If more nodes are required, create a service ticket to increase the quota.

extendParam

No

Table 14

Extended parameter. Format: Key-value pair.

Table 6 Data structure of the login field

Parameter

Mandatory

Type

Description

sshKey

No

String

Name of the key pair used for node login. For details on how to create a key pair, see Creating a Key Pair.

userPassword

No

Table 7

Password used for node login.

NOTE:

Only one login mode (key pair or password login mode) can be selected at a time. That is, you are not allowed to configure the sshKey and userPassword parameters at the same time.

Table 7 Data structure of the userPassword field

Parameter

Mandatory

Type

Description

username

Yes

String

Login account. The default value is root.

password

Yes

String

Node login password. For details about password settings, see the description of the adminPass parameter in the API that is used to create an ECS.

NOTE:

The value of the password field must be salted. The following is an example procedure for salting a password in Python environment:

  1. Generate a salt value.

    python -c "import crypt, getpass, pwd;print crypt.mksalt()"

    Command output:

    $6$KZ2u71CD4JjQneAy

  2. Add \ before $ in the salt value. Generate a ciphertext password based on the updated salt value.

    python -c "import crypt, getpass, pwd;print crypt.crypt('test@123','\$6\$KZ2u71CD4JjQneAy')"

    Command output:

    $6$KZ2u71CD4JjQneAy$WF5dsoOjTgc9RD46i46cCL3H92LMEo78s0rHdfSLDE8PW7ylE2ICcxUGF7/8RBbnxW0crgA3ZGNFA0LLgFaYD0

  3. Base64 encode the value of the password field.

    echo -n '$6$KZ2u71CD4JjQneAy$WF5dsoOjTgc9RD46i46cCL3H92LMEo78s0rHdfSLDE8PW7ylE2ICcxUGF7/8RBbnxW0crgA3ZGNFA0LLgFaYD0' | base64 | tr "\n" " " | sed s/[[:space:]]//g

    Command output:

    JDYkS1oydTcxQ0Q0SmpRbmVBeSRXRjVkc29PalRnYzlSRDQ2aTQ2Y0NMM0g5MkxNRW83OHMwckhkZlNMREU4UFc3eWxFMklDY3hVR0Y3LzhSQmJueFcwY3JnQTNaR05GQTBMTGdGYVlEMA==

Table 8 Data structure of the Volume field

Parameter

Mandatory

Type

Description

size

Yes

String

Disk size in the unit of GB.

  • System disk: 40 to 1,024
  • Data disk: 100 to 32,678

volumetype

Yes

String

Disk type. For details about possible values, see the description of the root_volume parameter in the API that is used to create an ECS.

  • SATA: common I/O disk type.
  • SATA: high I/O disk type.
  • SSD: ultra-high I/O disk type.

extendParam

No

String

Extended disk parameter. For details about possible values, see the description of the extendparam parameter in the API that is used to create an ECS.

Table 9 Data structure of the publicIP field

Parameter

Mandatory

Type

Description

ids

No

String

List of IDs of the existing EIPs.

NOTICE:

If ids is set, you do not need to set count and eip.

count

No

Integer

Number of EIPs to be dynamically created.

NOTICE:

The count and eip parameters must be set simultaneously.

eip

No

Table 10

EIP.

NOTICE:

The count and eip parameters must be set simultaneously.

NOTE:

If no EIP has been created, configure count and eip. The system will automatically create EIPs based on count and eip.

Table 10 Data structure of the eip field

Parameter

Mandatory

Type

Description

iptype

Yes

String

Type of the EIP. For details about possible values, see iptype parameter description in the table "eip field description" in Data Structure for Creating ECSs.

bandwidth

Yes

Table 11

Bandwidth parameters of the EIP.

Table 11 Data structure of the bandwidth field

Parameter

Mandatory

Type

Description

chargemode

No

String

Bandwidth billing mode.

  • If this parameter is not carried, the node is billed by bandwidth.
  • If this parameter is carried but is left blank, the node is billed by bandwidth.
  • If this parameter is set to traffic, the node is billed by traffic.
  • If this parameter is set to another value, node creation will fail.

size

Yes

Integer

Bandwidth size. For details, see size parameter description in the table "bandwidth field description" in Data Structure for Creating ECSs.

sharetype

Yes

String

Bandwidth sharing type. For details, see sharetype parameter description in the table "bandwidth field description" in Data Structure for Creating ECSs.

Example request:

Creating an ECS node in pay-per-use billing mode:

{
  "kind": "Node",
  "apiVersion": "v3",
  "metadata": {
    "name": "myhost",
    "labels": {
      "foo": "bar"
    },
    "annotations": {
      "annotation1": "abc"
    }
  },
  "spec": {
    "flavor": "s1.medium",
    "az": "az1.dc1",
    "login": {
      "sshKey": "myKeypair"
    },
    "rootVolume": {
      "size": 40,
      "volumetype": "SATA"
    },
    "dataVolumes": [
      {
        "size": 100,
        "volumetype": "SATA"
      }
    ],
    "publicIP": {
      "count": 2,
      "eip": {
        "iptype": "5_bgp",
        "bandwidth": {
         
          "size": 10,
          "sharetype": "PER"
        }
      }
    },
    "count": 2
  }
}

Response

Response parameters:

Table 12 describes the response parameters.

Table 12 Response parameters

Parameter

Type

Description

kind

String

API type. The value is fixed at Node and cannot be changed.

apiVersion

String

API version. The value is fixed at v3 and cannot be changed.

metadata

Table 4

Node's metadata, which is a collection of attributes. Empty metadata (metadata without containing any attributes) is not allowed.

spec

Table 13

Detailed description of the node targeted by this API. CCE creates or updates objects by defining or updating its spec.

status

Table 15

Node status and jobID of the node creation job.

Table 13 Data structure of the spec field

Parameter

Type

Description

flavor

String

Node flavor. For details, see the description of the flavorRef parameter in Help Center > Elastic Cloud Server > API Reference > Lifecycle Management > Creating ECSs.

az

String

Name of the AZ where the node resides. For details, see the description of the availability_zone parameter in Help Center > Elastic Cloud Server > API Reference > Lifecycle Management > Creating ECSs.

os

String

Node OS. Possible values:

  • EulerOS 2.2
  • CentOS 7.4

login

Table 6

Node login mode, which can be key pair or password.

rootVolume

Table 8

System disk parameters of the node.

dataVolumes

Table 8

Data disk parameters of the node. Currently, only one data disk can be configured.

publicIP

Table 9

EIP parameters of a node.

count

Integer

Quantity of nodes to be created at a time. The value must be a positive integer ranging from 1 to the maximum node limit. If more nodes are required, create a service ticket to increase the quota.

extendParam

Table 14

Extended parameter. Format: Key-value pair.

Table 14 Data structure of the extendParam field

Parameter

Type

Description

chargingMode

Integer

Billing mode of a node. Value 0 indicates pay-per-use. If this parameter is left unspecified, the default value 0 is used.

ecs:performancetype

String

Type of the ECS specifications.

orderID

String

Order ID. This parameter is mandatory in the yearly/monthly billing mode.

productID

String

Product ID.

Table 15 Data structure of the status field

Parameter

Type

Description

jobID

String

ID of the node creation job. You can query job progress by job ID to keep updated on node creation progress.

Example response:

{
  "kind": "Node",
  "apiVersion": "v3",
  "metadata": {
    "name": "myhost",
    "labels": {
      "foo": "bar"
    },
    "annotations": {
      "annotation1": "abc"
    }
  },
  "spec": {
    "flavor": "s1.medium",
    "az": "az1.dc1",
    "os": "EulerOS 2.2",
    "login": {
      "sshKey": "myKeypair",
      "userPassword": {}
    },
    "rootVolume": {
      "volumetype": "SATA",
      "size": 40
    },
    "dataVolumes": [
      {
        "volumetype": "SATA",
        "size": 100
      }
    ],
    "publicIP": {
      "count": 2,
      "eip": {
        "iptype": "5_bgp",
        "bandwidth": {
          "size": 10,
          "sharetype": "PER",
          "chargemode": "traffic"
        }
      }
    },
    "count": 2,
    "billingMode": 0,
    "extendParam": {
      "chargingMode": 0,
      "ecs:performancetype": "normal",
      "orderID": "",
      "productID": ""
    }
  },
  "status": {
    "jobID": "2ec9b78d-9368-46f3-8f29-d1a95622a568"
  }
}

Status Code

Table 16 describes the status code of this API.

Table 16 Status code

Status Code

Description

201

The job for creating a node in a specified cluster is successfully issued.

For the description about error status codes, see Status Code.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel