Creating a Node
Function
This API is used to create a node in a specified cluster.
![](https://support.huaweicloud.com/intl/en-us/api-cce/public_sys-resources/note_3.0-en-us.png)
If there is no cluster, create one.
The URL for cluster management is in the format of https://Endpoint/uri. In the URL, uri indicates the resource path, that is, the path for API access.
Constraints
Only KVM nodes can be created. Non-KVM nodes cannot be used after being created.
Calling Method
For details, see Calling APIs.
URI
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI. |
cluster_id |
Yes |
String |
Cluster ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
nodepoolScaleUp |
No |
String |
Whether the request is delivered by the node pool. If the value is not NodepoolScaleUp, the number of pods in the corresponding node pool is automatically updated. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Message body type (format). |
X-Auth-Token |
Yes |
String |
Requests for calling an 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, see Obtaining a User Token. |
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 |
No |
NodeMetadata object |
Node metadata, which is a collection of attributes. |
spec |
Yes |
NodeSpec object |
Detailed description of the node. CCE creates or updates objects by defining or updating spec. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Node name NOTE:
Enter 1 to 56 characters starting with a letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. If name is left empty or is not specified, the node name is generated based on the default rule, which is Cluster name-Random characters. Only the first 36 characters are kept for a long cluster name. If the number of nodes (count) is greater than 1, some random characters are added to the end of the entered node name according to the default rule, which is User-defined name-Random characters. Only the first 50 characters in the custom name are kept, followed by some random characters. Names of nodes running in clusters v1.28.1, v1.27.3, v1.25.6, v1.23.11, v1.21.12 or later support periods (.), but this configuration is not recommended. |
uid |
No |
String |
Node ID, which is unique and automatically generated after the resource is created. A user-defined ID will not take effect. |
labels |
No |
Map<String,String> |
CCE node label (not the native Kubernetes label). Labels are used to select objects that meet certain criteria. A label is a key-value pair. Example: "labels": { "key" : "value" } |
annotations |
No |
Map<String,String> |
CCE node annotations, in key-value pairs (not the native Kubernetes annotations). Example: "annotations": { "key1" : "value1", "key2" : "value2" } NOTE:
|
creationTimestamp |
No |
String |
Time when the object was created. The value is automatically generated after the object is created. A user-defined value will not take effect. |
updateTimestamp |
No |
String |
Time when the object was updated. The value is automatically generated after the object is created. A user-defined value will not take effect. |
ownerReference |
No |
ownerReference object |
Owner object |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
nodepoolName |
No |
String |
Node pool name |
nodepoolID |
No |
String |
Node pool UID |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
flavor |
Yes |
String |
Node specifications. For details about the node specifications supported by CCE, see Node Flavor Description. |
az |
Yes |
String |
AZ where the node to be created is located. You need to specify the AZ name. If it is set to random, the node will be created in a random AZ. For details about AZs supported by CCE, see Regions and Endpoints. |
os |
No |
String |
Node OS. For details about the supported OSs, see Node OS. NOTE:
|
login |
Yes |
Login object |
Node login mode. Either the key pair or password must be used for login. |
rootVolume |
Yes |
Volume object |
Information about disks on the node |
dataVolumes |
Yes |
Array of Volume objects |
Data disk parameters of a node. A VM can have up to 16 disks attached, while a BMS can only have up to 10 disks attached. The maximum number of disks that can be attached to either a VM or BMS is limited by their respective maximum disk limits. (You can add a second data disk for each of your nodes through the CCE console or API.) The data disk used by the container runtime and kubelet cannot be uninstalled, or the node will become unavailable. For DeC nodes, the parameter details are the same as those for rootVolume. |
storage |
No |
Storage object |
Disk initialization management parameter. This parameter is complex to configure. For details, see Attaching Disks to a Node. If this parameter retains its default, disks are managed based on the DockerLVMConfigOverride (discarded) parameter in extendParam. This parameter is supported by clusters of version 1.15.11 and later. NOTE:
NOTE:
NOTE:
|
publicIP |
No |
NodePublicIP object |
EIP of a node. NOTE:
This parameter is not supported when you add a node to a node pool. |
nodeNicSpec |
No |
NodeNicSpec object |
NIC of the node |
count |
No |
Integer |
Number of nodes to be created in a batch. The value must be a positive integer greater than or equal to 1 and less than or equal to the defined limit. This parameter can be left blank when it is used for a node pool. |
billingMode |
No |
Integer |
Node billing mode.
|
taints |
No |
Array of Taint objects |
You can add taints to created nodes to configure anti-affinity. A maximum of 20 taints can be added. Each taint contains the following parameters:
Example: "taints": [{ "key": "status", "value": "unavailable", "effect": "NoSchedule" }, { "key": "looks", "value": "bad", "effect": "NoSchedule" }] |
k8sTags |
No |
Map<String,String> |
Defined in key-value pairs. A maximum of 20 key-value pairs are allowed.
Example: "k8sTags": { "key": "value" } |
ecsGroupId |
No |
String |
ECS group ID. If this parameter is configured, nodes will be created in the specified ECS group. NOTE:
This configuration does not take effect when a node pool is created. To ensure that all nodes in a node pool are in the same ECS group, configure nodeManagement in the node pool. |
dedicatedHostId |
No |
String |
ID of the DeH to which the node is scheduled. NOTE:
This parameter is not supported when you add a node during node pool creation. |
userTags |
No |
Array of UserTag objects |
Cloud server tag. The key of a tag must be unique. The maximum number of custom tags supported by CCE depends on the region and cannot exceed 8. When creating a node, you can specify the initial value for this parameter and this field is not returned during query. In using node pools, the initial value can be specified in the node template and this field is returned during query. In other scenarios, this field is not returned during query. NOTE:
Use only letters, Unicode characters, digits, special characters(-,_). Max characters: 36 |
runtime |
No |
Runtime object |
Container runtime:
|
initializedConditions |
No |
Array of strings |
Custom initialization flag, which is left blank by default. Before CCE nodes are initialized, node.cloudprovider.kubernetes.io/uninitialized is added to the nodes to prevent pods from being scheduled to these nodes. When creating a node, you can configure the initializedConditions parameter to control the taint removal time. By default, the timeout period is not configured. Example:
status: conditions: - type: CCEInitial status: 'True' - type: CustomedInitial status: 'True'
|
extendParam |
No |
NodeExtendParam object |
Extended parameters for creating a node. |
hostnameConfig |
No |
HostnameConfig object |
Kubernetes node name configuration parameter, which is supported by clusters of v1.23.6-r0 to v1.25 or clusters of v1.25.2-r0 or later versions. |
serverEnterpriseProjectID |
No |
String |
Enterprise project ID of a server. CCE does not support features provided by EPS. This field is used only for synchronizing enterprise project IDs of servers. To create a node or node pool, you can specify an existing enterprise project for it. If this field is left blank, it inherits the enterprise project attributes of the cluster that runs the node or node pool. When updating a node pool, any configuration modifications you made will apply only to new nodes. You need to modify the enterprise projects of existing nodes on the EPS console. If no value is specified during the update, this field will not be updated. If this parameter is left blank, the cluster enterprise project is returned. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
sshKey |
No |
String |
Name of the key pair used for login. |
userPassword |
No |
UserPassword object |
Password used for node login. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
username |
No |
String |
Login account. The default value is root. |
password |
Yes |
String |
If a username and a password are used to create a node, this field is shielded in the response body. A password must meet the following complexity requirements:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
size |
Yes |
Integer |
Disk size, in GB.
|
volumetype |
Yes |
String |
Disk type. For details about possible values, see the description of the root_volume parameter in the API used to create an ECS.
|
extendParam |
No |
Map<String,Object> |
Extended disk parameters, defined in extendparam in the API used to create an ECS. For details, see Creating an ECS. |
cluster_id |
No |
String |
ID of the storage pool used by the ECS system disk. This field is used only for DeC clusters, which functions as dssPoolID, that is, the ID of the DSS storage pool. To obtain the value, see the ID field in the API used to obtain details of a DSS storage pool. |
cluster_type |
No |
String |
Storage class of the cloud server system disk. The value is always dss. This field is used only for DeC clusters. |
hw:passthrough |
No |
Boolean |
|
metadata |
No |
VolumeMetadata object |
EVS disk encryption information. This field is mandatory only when you need to encrypt the system disk or data disks of the node to be created. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
__system__encrypted |
No |
String |
Whether the EVS disk is encrypted. The value 0 indicates that the EVS disk is not encrypted, and the value 1 indicates that the EVS disk is encrypted. If this parameter is not specified, EVS disks will not be encrypted by default. |
__system__cmkid |
No |
String |
CMK ID, which indicates encryption in metadata. This field is used with __system__encrypted. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
storageSelectors |
Yes |
Array of StorageSelectors objects |
Disk selection. Matched disks are managed according to matchLabels and storageType. |
storageGroups |
Yes |
Array of StorageGroups objects |
A storage group consists of multiple storage devices. It is used to divide storage space. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Selector name, used as the index of selectorNames in storageGroup. Therefore, the name of each selector must be unique. |
storageType |
Yes |
String |
Storage type. Only evs (EVS disks) and local (local disks) are supported. The local storage does not support disk selection. All local disks will form a VG, so only one storageSelector of the local type is allowed. |
matchLabels |
No |
matchLabels object |
Matching field of an EVS volume. The size, volumeType, metadataEncrypted, metadataCmkid and count fields are supported. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
size |
No |
String |
Matched disk size. If this parameter is left unspecified, the disk size is not limited. Example: 100 |
volumeType |
No |
String |
EVS disk type. SSD, GPSSD, SAS, ESSD, and SATA are supported. If this parameter is left blank, there is no restriction on the disk type. |
metadataEncrypted |
No |
String |
Disk encryption identifier. If this parameter is set to 0, it specifies that the disk is not encrypted. If this parameter is set to 1, it specifies that the disk is encrypted. If this parameter is left blank, there is no restriction on the disk encryption identifier. |
metadataCmkid |
No |
String |
CMK ID of an encrypted disk. The value is a string of 36 bytes. If this parameter is left blank, there is no restriction on the disk key ID. |
count |
No |
String |
Number of disks to be selected. If this parameter is left blank, all disks of this type are selected. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Name of a virtual storage group, which must be unique. NOTE:
|
cceManaged |
No |
Boolean |
Storage space for Kubernetes and runtime components. Only one group can be set to true. If this parameter is left blank, the default value false is used. |
selectorNames |
Yes |
Array of strings |
Corresponds to name in storageSelectors. One group can select multiple selectors, but one selector can be selected by only one group. |
virtualSpaces |
Yes |
Array of VirtualSpace objects |
Detailed management of space configuration in a group. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
Yes |
String |
Name of a virtualSpace. Options: share, kubernetes, runtime, and user
|
size |
Yes |
String |
Size of a virtualSpace. The value must be an integer in percentage. Example: 90%. NOTE:
The sum of the percentages of all virtualSpaces in a group cannot exceed 100%. |
lvmConfig |
No |
LVMConfig object |
LVM configuration managements, applicable to the share*, kubernetes, and user spaces. Note that one virtual space supports only one config. |
runtimeConfig |
No |
RuntimeConfig object |
runtime configurations, applicable to the runtime space. Note that one virtual space supports only one config. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lvType |
Yes |
String |
LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. |
path |
No |
String |
Path to which the disk is attached. This parameter takes effect only in user configuration. The value is an absolute path. Digits, letters, periods (.), hyphens (-), and underscores (_) are allowed. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
lvType |
Yes |
String |
LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
ids |
No |
Array of strings |
IDs of existing EIPs. The quantity cannot be greater than the number of nodes to be created. NOTE:
If ids has been set, you do not need to set count and eip. |
count |
No |
Integer |
Number of EIPs to be dynamically created. NOTE:
count and eip must be set at the same time. |
eip |
No |
NodeEIPSpec object |
EIP configuration. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
iptype |
Yes |
String |
EIP type, specified in publicip.type in the API for assigning an EIP. For details, see Assigning an EIP. |
bandwidth |
No |
NodeBandwidth object |
Bandwidth parameters of the EIP |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
chargemode |
No |
String |
Bandwidth billing mode.
NOTE:
|
size |
No |
Integer |
Bandwidth size, specified in bandwidth.size in the API for assigning an EIP. For details, see Assigning an EIP. |
sharetype |
No |
String |
Bandwidth sharing type. Value options: PER (exclusive bandwidth) |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
primaryNic |
No |
NicSpec object |
Description of the primary NIC. |
extNics |
No |
Array of NicSpec objects |
Extension NIC NOTE:
This parameter is not supported when you add a node to a node pool. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnetId |
No |
String |
Network ID of the subnet to which a NIC belongs. If subnetId is not specified when a primary NIC is creating, the cluster subnet will be used. If subnetList is also configured for a node pool, the subnetList field is used for adding subnets to the node pool. When creating an extension NIC, you must specify subnetId. |
fixedIps |
No |
Array of strings |
The IP address of the primary ENI is specified using fixedIps. The number of IP addresses cannot be greater than the number of created nodes. Either fixedIps or ipBlock can be specified. fiexdIps cannot be specified for extension ENIs. |
ipBlock |
No |
String |
CIDR format of the primary NIC IP range. The IP address of the created node falls in this range. fixedIps and ipBlock cannot be specified at the same time. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
Yes |
String |
Key. |
value |
No |
String |
Value. |
effect |
Yes |
String |
Effect. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
key |
No |
String |
Key of the cloud server label. The value cannot start with CCE- or __type_baremetal. |
value |
No |
String |
Value of the cloud server label. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Container runtime. Default value:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
ecs:performancetype |
No |
String |
ECS flavor types. This field is returned in the response. |
orderID |
No |
String |
Order ID. This parameter is returned in the response when the node is billed on a yearly/monthly basis with auto payment enabled (only in creation scenarios). |
productID |
No |
String |
Product ID. This field is returned in the response when the node is yearly/monthly-billed with auto payment enabled. |
maxPods |
No |
Integer |
Maximum number of pods that can be created on a node, including the default system pods. Value range: 16 to 256. This limit prevents the node from being overloaded of pods. The number of pods that can be created on a node is determined by multiple parameters. For details, see Maximum Number of Pods That Can Be Created on a Node. |
periodType |
No |
String |
NOTE:
Request parameter, which is valid and mandatory only when billingMode is set to 1 (yearly/monthly billing) or 2 (yearly/monthly billing with auto renewal enabled) (discarded). Response parameter, which is returned only when a yearly/monthly node is created. |
periodNum |
No |
Integer |
Subscription duration. The value can be:
NOTE:
Request parameter, which is valid and mandatory when billingMode is set to 1 or 2 (discarded). Response parameter, which is returned only when a yearly/monthly node is created. |
isAutoRenew |
No |
String |
Whether auto renewal is enabled.
NOTE:
This field is valid when billingMode is set to 1 or 2 (discarded). If not specified, auto renewal is not enabled. |
isAutoPay |
No |
String |
Whether to deduct fees automatically.
NOTE:
This field is valid when billingMode is set to 1 or 2 (discarded). If not specified when billingMode is set to 1, auto fee deduction is not enabled. (Discarded: If not specified when billingMode is set to 2, auto fee deduction is enabled.) |
DockerLVMConfigOverride |
No |
String |
Docker data disk configuration item. (This parameter has been discarded. Use the storage field instead.) Example default configuration: "DockerLVMConfigOverride":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear" By default, if no VD disk is available, an error occurs because the data disk fails to be found. Set diskType based on the actual drive letter type. The following fields are included:
|
dockerBaseSize |
No |
Integer |
Available disk space of a single container on a node, in GB. This parameter has been discarded. Use containerBaseSize. If this parameter is left blank or is set to 0, the default value is used. In Device Mapper mode, the default value is 10. In OverlayFS mode, the available space of a single container is not limited by default, and the dockerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters of the new versions. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that dockerBaseSize be set to a value less than or equal to 80 GB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount an external or local storage device. |
containerBaseSize |
No |
Integer |
Available disk space of a single container on a node, in GB. If this parameter is left blank or is set to 0, the default value is used. In OverlayFS mode, the available space of a single container is not limited by default. In Device Mapper mode, the default value is 10, and the containerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0 or later. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that containerBaseSize be set to a value less than or equal to 80 GB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount an external or local storage device. In new versions, the Device Mapper mode is used only by BMSs in the same resource pool and is being discarded. |
publicKey |
No |
String |
Public key of a node. |
alpha.cce/preInstall |
No |
String |
Pre-installation script. NOTE:
The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64) |
alpha.cce/postInstall |
No |
String |
Post-installation script. NOTE:
The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64) |
alpha.cce/NodeImageID |
No |
String |
This parameter is required when a custom image is used to create a BMS node. |
nicMultiqueue |
No |
String |
"[{\"queue\":4}]" The following fields are included:
|
nicThreshold |
No |
String |
"0.3:0.6"
|
chargingMode |
No |
Integer |
Billing mode of a node. This parameter has been deprecated. Use the billingMode parameter in NodeSpec. |
marketType |
No |
String |
Specifies the market type. When creating a spot ECS, set this parameter to spot. NOTE:
This parameter is valid only when billingMode is set to 0. |
spotPrice |
No |
String |
Specifies the highest price per hour users accept for a spot ECS. NOTE:
This parameter takes effect only when billingMode is set to 0 and marketType is set to spot. When billingMode is set to 0 and marketType is set to spot, if spotPrice is not specified, the pay-per-use price is used by default. The spotPrice value must be less than or equal to the pay-per-use price and greater than or equal to the ECS market price. |
agency_name |
No |
String |
Name of an agency An agency is created by a tenant administrator on Identity and Access Management (IAM) to provide temporary credentials for CCE nodes to access cloud servers. This parameter is returned only when it is transferred during node creation. |
kubeReservedMem |
No |
Integer |
Reserved node memory, which is reserved for Kubernetes components. |
systemReservedMem |
No |
Integer |
Reserved node memory, which is reserved for system components. |
init-node-password |
No |
String |
Node password. If this parameter is used as a response parameter, asterisks (*) will be displayed. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Configuration type of the Kubernetes node name. The default value is privateIp.
NOTE:
|
Response Parameters
Status code: 201
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 |
NodeMetadata object |
Node metadata, which is a collection of attributes. |
spec |
NodeSpec object |
Detailed description of the node. CCE creates or updates objects by defining or updating spec. |
status |
NodeStatus object |
Node status, which is dynamically recorded. A user-defined value will not function when a node is being created or modified. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Node name NOTE:
Enter 1 to 56 characters starting with a letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. If name is left empty or is not specified, the node name is generated based on the default rule, which is Cluster name-Random characters. Only the first 36 characters are kept for a long cluster name. If the number of nodes (count) is greater than 1, some random characters are added to the end of the entered node name according to the default rule, which is User-defined name-Random characters. Only the first 50 characters in the custom name are kept, followed by some random characters. Names of nodes running in clusters v1.28.1, v1.27.3, v1.25.6, v1.23.11, v1.21.12 or later support periods (.), but this configuration is not recommended. |
uid |
String |
Node ID, which is unique and automatically generated after the resource is created. A user-defined ID will not take effect. |
labels |
Map<String,String> |
CCE node label (not the native Kubernetes label). Labels are used to select objects that meet certain criteria. A label is a key-value pair. Example: "labels": { "key" : "value" } |
annotations |
Map<String,String> |
CCE node annotations, in key-value pairs (not the native Kubernetes annotations). Example: "annotations": { "key1" : "value1", "key2" : "value2" } NOTE:
|
creationTimestamp |
String |
Time when the object was created. The value is automatically generated after the object is created. A user-defined value will not take effect. |
updateTimestamp |
String |
Time when the object was updated. The value is automatically generated after the object is created. A user-defined value will not take effect. |
ownerReference |
ownerReference object |
Owner object |
Parameter |
Type |
Description |
---|---|---|
nodepoolName |
String |
Node pool name |
nodepoolID |
String |
Node pool UID |
Parameter |
Type |
Description |
---|---|---|
flavor |
String |
Node specifications. For details about the node specifications supported by CCE, see Node Flavor Description. |
az |
String |
AZ where the node to be created is located. You need to specify the AZ name. If it is set to random, the node will be created in a random AZ. For details about AZs supported by CCE, see Regions and Endpoints. |
os |
String |
Node OS. For details about the supported OSs, see Node OS. NOTE:
|
login |
Login object |
Node login mode. Either the key pair or password must be used for login. |
rootVolume |
Volume object |
Information about disks on the node |
dataVolumes |
Array of Volume objects |
Data disk parameters of a node. A VM can have up to 16 disks attached, while a BMS can only have up to 10 disks attached. The maximum number of disks that can be attached to either a VM or BMS is limited by their respective maximum disk limits. (You can add a second data disk for each of your nodes through the CCE console or API.) The data disk used by the container runtime and kubelet cannot be uninstalled, or the node will become unavailable. For DeC nodes, the parameter details are the same as those for rootVolume. |
storage |
Storage object |
Disk initialization management parameter. This parameter is complex to configure. For details, see Attaching Disks to a Node. If this parameter retains its default, disks are managed based on the DockerLVMConfigOverride (discarded) parameter in extendParam. This parameter is supported by clusters of version 1.15.11 and later. NOTE:
NOTE:
NOTE:
|
publicIP |
NodePublicIP object |
EIP of a node. NOTE:
This parameter is not supported when you add a node to a node pool. |
nodeNicSpec |
NodeNicSpec object |
NIC of the node |
count |
Integer |
Number of nodes to be created in a batch. The value must be a positive integer greater than or equal to 1 and less than or equal to the defined limit. This parameter can be left blank when it is used for a node pool. |
billingMode |
Integer |
Node billing mode.
|
taints |
Array of Taint objects |
You can add taints to created nodes to configure anti-affinity. A maximum of 20 taints can be added. Each taint contains the following parameters:
Example: "taints": [{ "key": "status", "value": "unavailable", "effect": "NoSchedule" }, { "key": "looks", "value": "bad", "effect": "NoSchedule" }] |
k8sTags |
Map<String,String> |
Defined in key-value pairs. A maximum of 20 key-value pairs are allowed.
Example: "k8sTags": { "key": "value" } |
ecsGroupId |
String |
ECS group ID. If this parameter is configured, nodes will be created in the specified ECS group. NOTE:
This configuration does not take effect when a node pool is created. To ensure that all nodes in a node pool are in the same ECS group, configure nodeManagement in the node pool. |
dedicatedHostId |
String |
ID of the DeH to which the node is scheduled. NOTE:
This parameter is not supported when you add a node during node pool creation. |
userTags |
Array of UserTag objects |
Cloud server tag. The key of a tag must be unique. The maximum number of custom tags supported by CCE depends on the region and cannot exceed 8. When creating a node, you can specify the initial value for this parameter and this field is not returned during query. In using node pools, the initial value can be specified in the node template and this field is returned during query. In other scenarios, this field is not returned during query. NOTE:
Use only letters, Unicode characters, digits, special characters(-,_). Max characters: 36 |
runtime |
Runtime object |
Container runtime:
|
initializedConditions |
Array of strings |
Custom initialization flag, which is left blank by default. Before CCE nodes are initialized, node.cloudprovider.kubernetes.io/uninitialized is added to the nodes to prevent pods from being scheduled to these nodes. When creating a node, you can configure the initializedConditions parameter to control the taint removal time. By default, the timeout period is not configured. Example:
status: conditions: - type: CCEInitial status: 'True' - type: CustomedInitial status: 'True'
|
extendParam |
NodeExtendParam object |
Extended parameters for creating a node. |
hostnameConfig |
HostnameConfig object |
Kubernetes node name configuration parameter, which is supported by clusters of v1.23.6-r0 to v1.25 or clusters of v1.25.2-r0 or later versions. |
serverEnterpriseProjectID |
String |
Enterprise project ID of a server. CCE does not support features provided by EPS. This field is used only for synchronizing enterprise project IDs of servers. To create a node or node pool, you can specify an existing enterprise project for it. If this field is left blank, it inherits the enterprise project attributes of the cluster that runs the node or node pool. When updating a node pool, any configuration modifications you made will apply only to new nodes. You need to modify the enterprise projects of existing nodes on the EPS console. If no value is specified during the update, this field will not be updated. If this parameter is left blank, the cluster enterprise project is returned. |
Parameter |
Type |
Description |
---|---|---|
sshKey |
String |
Name of the key pair used for login. |
userPassword |
UserPassword object |
Password used for node login. |
Parameter |
Type |
Description |
---|---|---|
username |
String |
Login account. The default value is root. |
password |
String |
If a username and a password are used to create a node, this field is shielded in the response body. A password must meet the following complexity requirements:
|
Parameter |
Type |
Description |
---|---|---|
size |
Integer |
Disk size, in GB.
|
volumetype |
String |
Disk type. For details about possible values, see the description of the root_volume parameter in the API used to create an ECS.
|
extendParam |
Map<String,Object> |
Extended disk parameters, defined in extendparam in the API used to create an ECS. For details, see Creating an ECS. |
cluster_id |
String |
ID of the storage pool used by the ECS system disk. This field is used only for DeC clusters, which functions as dssPoolID, that is, the ID of the DSS storage pool. To obtain the value, see the ID field in the API used to obtain details of a DSS storage pool. |
cluster_type |
String |
Storage class of the cloud server system disk. The value is always dss. This field is used only for DeC clusters. |
hw:passthrough |
Boolean |
|
metadata |
VolumeMetadata object |
EVS disk encryption information. This field is mandatory only when you need to encrypt the system disk or data disks of the node to be created. |
Parameter |
Type |
Description |
---|---|---|
__system__encrypted |
String |
Whether the EVS disk is encrypted. The value 0 indicates that the EVS disk is not encrypted, and the value 1 indicates that the EVS disk is encrypted. If this parameter is not specified, EVS disks will not be encrypted by default. |
__system__cmkid |
String |
CMK ID, which indicates encryption in metadata. This field is used with __system__encrypted. |
Parameter |
Type |
Description |
---|---|---|
storageSelectors |
Array of StorageSelectors objects |
Disk selection. Matched disks are managed according to matchLabels and storageType. |
storageGroups |
Array of StorageGroups objects |
A storage group consists of multiple storage devices. It is used to divide storage space. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Selector name, used as the index of selectorNames in storageGroup. Therefore, the name of each selector must be unique. |
storageType |
String |
Storage type. Only evs (EVS disks) and local (local disks) are supported. The local storage does not support disk selection. All local disks will form a VG, so only one storageSelector of the local type is allowed. |
matchLabels |
matchLabels object |
Matching field of an EVS volume. The size, volumeType, metadataEncrypted, metadataCmkid and count fields are supported. |
Parameter |
Type |
Description |
---|---|---|
size |
String |
Matched disk size. If this parameter is left unspecified, the disk size is not limited. Example: 100 |
volumeType |
String |
EVS disk type. SSD, GPSSD, SAS, ESSD, and SATA are supported. If this parameter is left blank, there is no restriction on the disk type. |
metadataEncrypted |
String |
Disk encryption identifier. If this parameter is set to 0, it specifies that the disk is not encrypted. If this parameter is set to 1, it specifies that the disk is encrypted. If this parameter is left blank, there is no restriction on the disk encryption identifier. |
metadataCmkid |
String |
CMK ID of an encrypted disk. The value is a string of 36 bytes. If this parameter is left blank, there is no restriction on the disk key ID. |
count |
String |
Number of disks to be selected. If this parameter is left blank, all disks of this type are selected. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Name of a virtual storage group, which must be unique. NOTE:
|
cceManaged |
Boolean |
Storage space for Kubernetes and runtime components. Only one group can be set to true. If this parameter is left blank, the default value false is used. |
selectorNames |
Array of strings |
Corresponds to name in storageSelectors. One group can select multiple selectors, but one selector can be selected by only one group. |
virtualSpaces |
Array of VirtualSpace objects |
Detailed management of space configuration in a group. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Name of a virtualSpace. Options: share, kubernetes, runtime, and user
|
size |
String |
Size of a virtualSpace. The value must be an integer in percentage. Example: 90%. NOTE:
The sum of the percentages of all virtualSpaces in a group cannot exceed 100%. |
lvmConfig |
LVMConfig object |
LVM configuration managements, applicable to the share*, kubernetes, and user spaces. Note that one virtual space supports only one config. |
runtimeConfig |
RuntimeConfig object |
runtime configurations, applicable to the runtime space. Note that one virtual space supports only one config. |
Parameter |
Type |
Description |
---|---|---|
lvType |
String |
LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. |
path |
String |
Path to which the disk is attached. This parameter takes effect only in user configuration. The value is an absolute path. Digits, letters, periods (.), hyphens (-), and underscores (_) are allowed. |
Parameter |
Type |
Description |
---|---|---|
lvType |
String |
LVM write mode. linear indicates the linear mode. striped indicates the striped mode, in which multiple disks are used to form a strip to improve disk performance. |
Parameter |
Type |
Description |
---|---|---|
ids |
Array of strings |
IDs of existing EIPs. The quantity cannot be greater than the number of nodes to be created. NOTE:
If ids has been set, you do not need to set count and eip. |
count |
Integer |
Number of EIPs to be dynamically created. NOTE:
count and eip must be set at the same time. |
eip |
NodeEIPSpec object |
EIP configuration. |
Parameter |
Type |
Description |
---|---|---|
iptype |
String |
EIP type, specified in publicip.type in the API for assigning an EIP. For details, see Assigning an EIP. |
bandwidth |
NodeBandwidth object |
Bandwidth parameters of the EIP |
Parameter |
Type |
Description |
---|---|---|
chargemode |
String |
Bandwidth billing mode.
NOTE:
|
size |
Integer |
Bandwidth size, specified in bandwidth.size in the API for assigning an EIP. For details, see Assigning an EIP. |
sharetype |
String |
Bandwidth sharing type. Value options: PER (exclusive bandwidth) |
Parameter |
Type |
Description |
---|---|---|
primaryNic |
NicSpec object |
Description of the primary NIC. |
extNics |
Array of NicSpec objects |
Extension NIC NOTE:
This parameter is not supported when you add a node to a node pool. |
Parameter |
Type |
Description |
---|---|---|
subnetId |
String |
Network ID of the subnet to which a NIC belongs. If subnetId is not specified when a primary NIC is creating, the cluster subnet will be used. If subnetList is also configured for a node pool, the subnetList field is used for adding subnets to the node pool. When creating an extension NIC, you must specify subnetId. |
fixedIps |
Array of strings |
The IP address of the primary ENI is specified using fixedIps. The number of IP addresses cannot be greater than the number of created nodes. Either fixedIps or ipBlock can be specified. fiexdIps cannot be specified for extension ENIs. |
ipBlock |
String |
CIDR format of the primary NIC IP range. The IP address of the created node falls in this range. fixedIps and ipBlock cannot be specified at the same time. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Key of the cloud server label. The value cannot start with CCE- or __type_baremetal. |
value |
String |
Value of the cloud server label. |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Container runtime. Default value:
|
Parameter |
Type |
Description |
---|---|---|
ecs:performancetype |
String |
ECS flavor types. This field is returned in the response. |
orderID |
String |
Order ID. This parameter is returned in the response when the node is billed on a yearly/monthly basis with auto payment enabled (only in creation scenarios). |
productID |
String |
Product ID. This field is returned in the response when the node is yearly/monthly-billed with auto payment enabled. |
maxPods |
Integer |
Maximum number of pods that can be created on a node, including the default system pods. Value range: 16 to 256. This limit prevents the node from being overloaded of pods. The number of pods that can be created on a node is determined by multiple parameters. For details, see Maximum Number of Pods That Can Be Created on a Node. |
periodType |
String |
NOTE:
Request parameter, which is valid and mandatory only when billingMode is set to 1 (yearly/monthly billing) or 2 (yearly/monthly billing with auto renewal enabled) (discarded). Response parameter, which is returned only when a yearly/monthly node is created. |
periodNum |
Integer |
Subscription duration. The value can be:
NOTE:
Request parameter, which is valid and mandatory when billingMode is set to 1 or 2 (discarded). Response parameter, which is returned only when a yearly/monthly node is created. |
isAutoRenew |
String |
Whether auto renewal is enabled.
NOTE:
This field is valid when billingMode is set to 1 or 2 (discarded). If not specified, auto renewal is not enabled. |
isAutoPay |
String |
Whether to deduct fees automatically.
NOTE:
This field is valid when billingMode is set to 1 or 2 (discarded). If not specified when billingMode is set to 1, auto fee deduction is not enabled. (Discarded: If not specified when billingMode is set to 2, auto fee deduction is enabled.) |
DockerLVMConfigOverride |
String |
Docker data disk configuration item. (This parameter has been discarded. Use the storage field instead.) Example default configuration: "DockerLVMConfigOverride":"dockerThinpool=vgpaas/90%VG;kubernetesLV=vgpaas/10%VG;diskType=evs;lvType=linear" By default, if no VD disk is available, an error occurs because the data disk fails to be found. Set diskType based on the actual drive letter type. The following fields are included:
|
dockerBaseSize |
Integer |
Available disk space of a single container on a node, in GB. This parameter has been discarded. Use containerBaseSize. If this parameter is left blank or is set to 0, the default value is used. In Device Mapper mode, the default value is 10. In OverlayFS mode, the available space of a single container is not limited by default, and the dockerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters of the new versions. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that dockerBaseSize be set to a value less than or equal to 80 GB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount an external or local storage device. |
containerBaseSize |
Integer |
Available disk space of a single container on a node, in GB. If this parameter is left blank or is set to 0, the default value is used. In OverlayFS mode, the available space of a single container is not limited by default. In Device Mapper mode, the default value is 10, and the containerBaseSize setting takes effect only on nodes running EulerOS/Huawei Cloud EulerOS 2.0 in clusters v1.23.14-r0, v1.25.9-r0, v1.27.6-r0, v1.28.4-r0 or later. For details about how to allocate the space for the container runtime, see Data Disk Space Allocation. When Device Mapper is used, it is recommended that containerBaseSize be set to a value less than or equal to 80 GB. If the value is too large, the container runtime may fail to be started due to long initialization. If there are special requirements for the container disk space, you can mount an external or local storage device. In new versions, the Device Mapper mode is used only by BMSs in the same resource pool and is being discarded. |
publicKey |
String |
Public key of a node. |
alpha.cce/preInstall |
String |
Pre-installation script. NOTE:
The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64) |
alpha.cce/postInstall |
String |
Post-installation script. NOTE:
The input value must be Base64-encoded. (Command: echo -n "Content to be encoded" | base64) |
alpha.cce/NodeImageID |
String |
This parameter is required when a custom image is used to create a BMS node. |
nicMultiqueue |
String |
"[{\"queue\":4}]" The following fields are included:
|
nicThreshold |
String |
"0.3:0.6"
|
chargingMode |
Integer |
Billing mode of a node. This parameter has been deprecated. Use the billingMode parameter in NodeSpec. |
marketType |
String |
Specifies the market type. When creating a spot ECS, set this parameter to spot. NOTE:
This parameter is valid only when billingMode is set to 0. |
spotPrice |
String |
Specifies the highest price per hour users accept for a spot ECS. NOTE:
This parameter takes effect only when billingMode is set to 0 and marketType is set to spot. When billingMode is set to 0 and marketType is set to spot, if spotPrice is not specified, the pay-per-use price is used by default. The spotPrice value must be less than or equal to the pay-per-use price and greater than or equal to the ECS market price. |
agency_name |
String |
Name of an agency An agency is created by a tenant administrator on Identity and Access Management (IAM) to provide temporary credentials for CCE nodes to access cloud servers. This parameter is returned only when it is transferred during node creation. |
kubeReservedMem |
Integer |
Reserved node memory, which is reserved for Kubernetes components. |
systemReservedMem |
Integer |
Reserved node memory, which is reserved for system components. |
init-node-password |
String |
Node password. If this parameter is used as a response parameter, asterisks (*) will be displayed. |
Parameter |
Type |
Description |
---|---|---|
type |
String |
Configuration type of the Kubernetes node name. The default value is privateIp.
NOTE:
|
Parameter |
Type |
Description |
---|---|---|
phase |
String |
Node status, which is the status of a node during its lifecycle (such as installation and uninstallation) or the status of a node in a Kubernetes cluster. Options:
|
lastProbeTime |
String |
Last time when the node status was checked. If the cluster is in the abnormal, frozen, or intermediate state (for example, creating), the node status check may be affected. The node status that takes more than five minutes to check has no reference value. |
jobID |
String |
ID of a creation or deletion job |
serverId |
String |
ID of the underlying ECS or BMS node |
privateIP |
String |
IP address in the private network segment of the primary NIC on the node |
privateIPv6IP |
String |
IPv6 address in the private network segment of the primary NIC on the node |
publicIP |
String |
Node EIP. If the ECS data is not synchronized in real time, you can click Sync Node Data on the console to manually update the data. |
deleteStatus |
DeleteStatus object |
Resource status during resource deletion. |
Parameter |
Type |
Description |
---|---|---|
previous_total |
Integer |
Total number of existing cluster resource records when the cluster is deleted. |
current_total |
Integer |
Latest number of resource records, which is generated based on the current cluster resource records. |
updated |
Integer |
Total number of resource records updated when the cluster is deleted. |
added |
Integer |
Total number of resource records updated when the cluster is deleted. |
deleted |
Integer |
Total number of resource records deleted when the cluster is deleted. |
Example Requests
Create a yearly/monthly node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes { "kind" : "Node", "apiVersion" : "v3", "metadata" : { "name" : "test-67235" }, "spec" : { "flavor" : "c7.large.2", "az" : "******", "os" : "EulerOS 2.5", "dataVolumes" : [ { "size" : 100, "volumetype" : "SAS" } ], "billingMode" : 1, "extendParam" : { "maxPods" : 110, "periodType" : "month", "periodNum" : 1, "isAutoPay" : "false", "isAutoRenew" : "false" }, "nodeNicSpec" : { "primaryNic" : { "subnetId" : "ca964acf-8468-4735-8229-97940ef6c881" } }, "rootVolume" : { "size" : 50, "volumetype" : "SAS" }, "runtime" : { "name" : "docker" }, "login" : { "sshKey" : "KeyPair-001" }, "storage" : { "storageSelectors" : [ { "name" : "cceUse", "storageType" : "evs", "matchLabels" : { "size" : "100", "volumeType" : "SAS", "count" : "1" } } ], "storageGroups" : [ { "name" : "vgpaas", "selectorNames" : [ "cceUse" ], "cceManaged" : true, "virtualSpaces" : [ { "name" : "runtime", "size" : "90%" }, { "name" : "kubernetes", "size" : "10%" } ] } ] }, "count" : 1 } }
Create a pay-per-use node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes { "kind" : "Node", "apiVersion" : "v3", "metadata" : { "name" : "test-83790" }, "spec" : { "flavor" : "c7.large.2", "az" : "******", "os" : "EulerOS 2.5", "dataVolumes" : [ { "size" : 100, "volumetype" : "SAS" } ], "billingMode" : 0, "extendParam" : { "maxPods" : 110 }, "nodeNicSpec" : { "primaryNic" : { "subnetId" : "ca964acf-8468-4735-8229-97940ef6c881" } }, "rootVolume" : { "size" : 50, "volumetype" : "SAS" }, "runtime" : { "name" : "docker" }, "login" : { "sshKey" : "KeyPair-001" }, "storage" : { "storageSelectors" : [ { "name" : "cceUse", "storageType" : "evs", "matchLabels" : { "size" : "100", "volumeType" : "SAS", "count" : "1" } } ], "storageGroups" : [ { "name" : "vgpaas", "selectorNames" : [ "cceUse" ], "cceManaged" : true, "virtualSpaces" : [ { "name" : "runtime", "size" : "90%" }, { "name" : "kubernetes", "size" : "10%" } ] } ] }, "count" : 1 } }
Create a pay-per-usenode with the flavor of 2 vCPUs and 4 GiB of memory. The node runs Huawei Cloud EulerOS 2.0 and uses Docker. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. The data disk uses the shared disk space mode.
POST /api/v3/projects/{project_id}/clusters/{cluster_id}/nodes { "kind" : "Node", "apiVersion" : "v3", "metadata" : { "name" : "test-66909" }, "spec" : { "flavor" : "c7.large.2", "az" : "******", "os" : "Huawei Cloud EulerOS 2.0", "dataVolumes" : [ { "size" : 100, "volumetype" : "SAS" } ], "billingMode" : 0, "extendParam" : { "maxPods" : 110 }, "nodeNicSpec" : { "primaryNic" : { "subnetId" : "ca964acf-8468-4735-8229-97940ef6c881" } }, "rootVolume" : { "size" : 50, "volumetype" : "SAS" }, "runtime" : { "name" : "docker" }, "login" : { "sshKey" : "KeyPair-001" }, "storage" : { "storageSelectors" : [ { "name" : "cceUse", "storageType" : "evs", "matchLabels" : { "size" : "100", "volumeType" : "SAS", "count" : "1" } } ], "storageGroups" : [ { "name" : "vgpaas", "selectorNames" : [ "cceUse" ], "cceManaged" : true, "virtualSpaces" : [ { "name" : "share", "size" : "100%" } ] } ] }, "count" : 1 } }
Example Responses
Status code: 201
The job for creating a node in a specified cluster is successfully delivered.
{ "kind" : "Node", "apiVersion" : "v3", "metadata" : { "name" : "test-83790", "uid" : "5ecfddfe-87db-11ec-b5e5-0255ac101514", "annotations" : { "jobid" : "5ec1518c-87db-11ec-b5e5-0255ac101514", "resourceJobId" : "5ed0d692-87db-11ec-b5e5-0255ac101514" } }, "spec" : { "flavor" : "c7.large.2", "az" : "******", "os" : "EulerOS 2.5", "login" : { "sshKey" : "KeyPair-001" }, "rootVolume" : { "volumetype" : "SAS", "size" : 50 }, "dataVolumes" : [ { "volumetype" : "SAS", "size" : 100 } ], "storage" : { "storageSelectors" : [ { "name" : "cceUse", "storageType" : "evs", "matchLabels" : { "count" : "1", "size" : "100", "volumeType" : "SAS" } } ], "storageGroups" : [ { "name" : "vgpaas", "cceManaged" : true, "selectorNames" : [ "cceUse" ], "virtualSpaces" : [ { "name" : "runtime", "size" : "90%" }, { "name" : "kubernetes", "size" : "10%" } ] } ] }, "publicIP" : { "eip" : { "bandwidth" : { } } }, "nodeNicSpec" : { "primaryNic" : { "subnetId" : "ca964acf-8468-4735-8229-97940ef6c881" } }, "count" : 1, "billingMode" : 0, "runtime" : { "name" : "docker" }, "extendParam" : { "chargingMode" : 0, "ecs:performancetype" : "computingv3", "init-node-password" : "******", "maxPods" : 110, "publicKey" : "" } }, "status" : { "jobID" : "5ec1518c-87db-11ec-b5e5-0255ac101514" } }
SDK Sample Code
The SDK sample code is as follows.
Create a yearly/monthly node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import com.huaweicloud.sdk.cce.v3.model.Runtime; import java.util.List; import java.util.ArrayList; public class CreateNodeSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); CreateNodeRequest request = new CreateNodeRequest(); request.withClusterId("{cluster_id}"); NodeCreateRequest body = new NodeCreateRequest(); NodeExtendParam extendParamSpec = new NodeExtendParam(); extendParamSpec.withMaxPods(110) .withPeriodType("month") .withPeriodNum(1) .withIsAutoRenew("false") .withIsAutoPay("false"); Runtime runtimeSpec = new Runtime(); runtimeSpec.withName(Runtime.NameEnum.fromValue("docker")); NicSpec primaryNicNodeNicSpec = new NicSpec(); primaryNicNodeNicSpec.withSubnetId("ca964acf-8468-4735-8229-97940ef6c881"); NodeNicSpec nodeNicSpecSpec = new NodeNicSpec(); nodeNicSpecSpec.withPrimaryNic(primaryNicNodeNicSpec); List<VirtualSpace> listStorageGroupsVirtualSpaces = new ArrayList<>(); listStorageGroupsVirtualSpaces.add( new VirtualSpace() .withName("runtime") .withSize("90%") ); listStorageGroupsVirtualSpaces.add( new VirtualSpace() .withName("kubernetes") .withSize("10%") ); List<String> listStorageGroupsSelectorNames = new ArrayList<>(); listStorageGroupsSelectorNames.add("cceUse"); List<StorageGroups> listStorageStorageGroups = new ArrayList<>(); listStorageStorageGroups.add( new StorageGroups() .withName("vgpaas") .withCceManaged(true) .withSelectorNames(listStorageGroupsSelectorNames) .withVirtualSpaces(listStorageGroupsVirtualSpaces) ); StorageSelectorsMatchLabels matchLabelsStorageSelectors = new StorageSelectorsMatchLabels(); matchLabelsStorageSelectors.withSize("100") .withVolumeType("SAS") .withCount("1"); List<StorageSelectors> listStorageStorageSelectors = new ArrayList<>(); listStorageStorageSelectors.add( new StorageSelectors() .withName("cceUse") .withStorageType("evs") .withMatchLabels(matchLabelsStorageSelectors) ); Storage storageSpec = new Storage(); storageSpec.withStorageSelectors(listStorageStorageSelectors) .withStorageGroups(listStorageStorageGroups); List<Volume> listSpecDataVolumes = new ArrayList<>(); listSpecDataVolumes.add( new Volume() .withSize(100) .withVolumetype("SAS") ); Volume rootVolumeSpec = new Volume(); rootVolumeSpec.withSize(50) .withVolumetype("SAS"); Login loginSpec = new Login(); loginSpec.withSshKey("KeyPair-001"); NodeSpec specbody = new NodeSpec(); specbody.withFlavor("c7.large.2") .withAz("******") .withOs("EulerOS 2.5") .withLogin(loginSpec) .withRootVolume(rootVolumeSpec) .withDataVolumes(listSpecDataVolumes) .withStorage(storageSpec) .withNodeNicSpec(nodeNicSpecSpec) .withCount(1) .withBillingMode(1) .withRuntime(runtimeSpec) .withExtendParam(extendParamSpec); NodeMetadata metadatabody = new NodeMetadata(); metadatabody.withName("test-67235"); body.withSpec(specbody); body.withMetadata(metadatabody); body.withApiVersion("v3"); body.withKind("Node"); request.withBody(body); try { CreateNodeResponse response = client.createNode(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
Create a pay-per-use node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import com.huaweicloud.sdk.cce.v3.model.Runtime; import java.util.List; import java.util.ArrayList; public class CreateNodeSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); CreateNodeRequest request = new CreateNodeRequest(); request.withClusterId("{cluster_id}"); NodeCreateRequest body = new NodeCreateRequest(); NodeExtendParam extendParamSpec = new NodeExtendParam(); extendParamSpec.withMaxPods(110); Runtime runtimeSpec = new Runtime(); runtimeSpec.withName(Runtime.NameEnum.fromValue("docker")); NicSpec primaryNicNodeNicSpec = new NicSpec(); primaryNicNodeNicSpec.withSubnetId("ca964acf-8468-4735-8229-97940ef6c881"); NodeNicSpec nodeNicSpecSpec = new NodeNicSpec(); nodeNicSpecSpec.withPrimaryNic(primaryNicNodeNicSpec); List<VirtualSpace> listStorageGroupsVirtualSpaces = new ArrayList<>(); listStorageGroupsVirtualSpaces.add( new VirtualSpace() .withName("runtime") .withSize("90%") ); listStorageGroupsVirtualSpaces.add( new VirtualSpace() .withName("kubernetes") .withSize("10%") ); List<String> listStorageGroupsSelectorNames = new ArrayList<>(); listStorageGroupsSelectorNames.add("cceUse"); List<StorageGroups> listStorageStorageGroups = new ArrayList<>(); listStorageStorageGroups.add( new StorageGroups() .withName("vgpaas") .withCceManaged(true) .withSelectorNames(listStorageGroupsSelectorNames) .withVirtualSpaces(listStorageGroupsVirtualSpaces) ); StorageSelectorsMatchLabels matchLabelsStorageSelectors = new StorageSelectorsMatchLabels(); matchLabelsStorageSelectors.withSize("100") .withVolumeType("SAS") .withCount("1"); List<StorageSelectors> listStorageStorageSelectors = new ArrayList<>(); listStorageStorageSelectors.add( new StorageSelectors() .withName("cceUse") .withStorageType("evs") .withMatchLabels(matchLabelsStorageSelectors) ); Storage storageSpec = new Storage(); storageSpec.withStorageSelectors(listStorageStorageSelectors) .withStorageGroups(listStorageStorageGroups); List<Volume> listSpecDataVolumes = new ArrayList<>(); listSpecDataVolumes.add( new Volume() .withSize(100) .withVolumetype("SAS") ); Volume rootVolumeSpec = new Volume(); rootVolumeSpec.withSize(50) .withVolumetype("SAS"); Login loginSpec = new Login(); loginSpec.withSshKey("KeyPair-001"); NodeSpec specbody = new NodeSpec(); specbody.withFlavor("c7.large.2") .withAz("******") .withOs("EulerOS 2.5") .withLogin(loginSpec) .withRootVolume(rootVolumeSpec) .withDataVolumes(listSpecDataVolumes) .withStorage(storageSpec) .withNodeNicSpec(nodeNicSpecSpec) .withCount(1) .withBillingMode(0) .withRuntime(runtimeSpec) .withExtendParam(extendParamSpec); NodeMetadata metadatabody = new NodeMetadata(); metadatabody.withName("test-83790"); body.withSpec(specbody); body.withMetadata(metadatabody); body.withApiVersion("v3"); body.withKind("Node"); request.withBody(body); try { CreateNodeResponse response = client.createNode(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
Create a pay-per-usenode with the flavor of 2 vCPUs and 4 GiB of memory. The node runs Huawei Cloud EulerOS 2.0 and uses Docker. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. The data disk uses the shared disk space mode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.cce.v3.region.CceRegion; import com.huaweicloud.sdk.cce.v3.*; import com.huaweicloud.sdk.cce.v3.model.*; import com.huaweicloud.sdk.cce.v3.model.Runtime; import java.util.List; import java.util.ArrayList; public class CreateNodeSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); CreateNodeRequest request = new CreateNodeRequest(); request.withClusterId("{cluster_id}"); NodeCreateRequest body = new NodeCreateRequest(); NodeExtendParam extendParamSpec = new NodeExtendParam(); extendParamSpec.withMaxPods(110); Runtime runtimeSpec = new Runtime(); runtimeSpec.withName(Runtime.NameEnum.fromValue("docker")); NicSpec primaryNicNodeNicSpec = new NicSpec(); primaryNicNodeNicSpec.withSubnetId("ca964acf-8468-4735-8229-97940ef6c881"); NodeNicSpec nodeNicSpecSpec = new NodeNicSpec(); nodeNicSpecSpec.withPrimaryNic(primaryNicNodeNicSpec); List<VirtualSpace> listStorageGroupsVirtualSpaces = new ArrayList<>(); listStorageGroupsVirtualSpaces.add( new VirtualSpace() .withName("share") .withSize("100%") ); List<String> listStorageGroupsSelectorNames = new ArrayList<>(); listStorageGroupsSelectorNames.add("cceUse"); List<StorageGroups> listStorageStorageGroups = new ArrayList<>(); listStorageStorageGroups.add( new StorageGroups() .withName("vgpaas") .withCceManaged(true) .withSelectorNames(listStorageGroupsSelectorNames) .withVirtualSpaces(listStorageGroupsVirtualSpaces) ); StorageSelectorsMatchLabels matchLabelsStorageSelectors = new StorageSelectorsMatchLabels(); matchLabelsStorageSelectors.withSize("100") .withVolumeType("SAS") .withCount("1"); List<StorageSelectors> listStorageStorageSelectors = new ArrayList<>(); listStorageStorageSelectors.add( new StorageSelectors() .withName("cceUse") .withStorageType("evs") .withMatchLabels(matchLabelsStorageSelectors) ); Storage storageSpec = new Storage(); storageSpec.withStorageSelectors(listStorageStorageSelectors) .withStorageGroups(listStorageStorageGroups); List<Volume> listSpecDataVolumes = new ArrayList<>(); listSpecDataVolumes.add( new Volume() .withSize(100) .withVolumetype("SAS") ); Volume rootVolumeSpec = new Volume(); rootVolumeSpec.withSize(50) .withVolumetype("SAS"); Login loginSpec = new Login(); loginSpec.withSshKey("KeyPair-001"); NodeSpec specbody = new NodeSpec(); specbody.withFlavor("c7.large.2") .withAz("******") .withOs("Huawei Cloud EulerOS 2.0") .withLogin(loginSpec) .withRootVolume(rootVolumeSpec) .withDataVolumes(listSpecDataVolumes) .withStorage(storageSpec) .withNodeNicSpec(nodeNicSpecSpec) .withCount(1) .withBillingMode(0) .withRuntime(runtimeSpec) .withExtendParam(extendParamSpec); NodeMetadata metadatabody = new NodeMetadata(); metadatabody.withName("test-66909"); body.withSpec(specbody); body.withMetadata(metadatabody); body.withApiVersion("v3"); body.withKind("Node"); request.withBody(body); try { CreateNodeResponse response = client.createNode(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } }
Create a yearly/monthly node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateNodeRequest() request.cluster_id = "{cluster_id}" extendParamSpec = NodeExtendParam( max_pods=110, period_type="month", period_num=1, is_auto_renew="false", is_auto_pay="false" ) runtimeSpec = Runtime( name="docker" ) primaryNicNodeNicSpec = NicSpec( subnet_id="ca964acf-8468-4735-8229-97940ef6c881" ) nodeNicSpecSpec = NodeNicSpec( primary_nic=primaryNicNodeNicSpec ) listVirtualSpacesStorageGroups = [ VirtualSpace( name="runtime", size="90%" ), VirtualSpace( name="kubernetes", size="10%" ) ] listSelectorNamesStorageGroups = [ "cceUse" ] listStorageGroupsStorage = [ StorageGroups( name="vgpaas", cce_managed=True, selector_names=listSelectorNamesStorageGroups, virtual_spaces=listVirtualSpacesStorageGroups ) ] matchLabelsStorageSelectors = StorageSelectorsMatchLabels( size="100", volume_type="SAS", count="1" ) listStorageSelectorsStorage = [ StorageSelectors( name="cceUse", storage_type="evs", match_labels=matchLabelsStorageSelectors ) ] storageSpec = Storage( storage_selectors=listStorageSelectorsStorage, storage_groups=listStorageGroupsStorage ) listDataVolumesSpec = [ Volume( size=100, volumetype="SAS" ) ] rootVolumeSpec = Volume( size=50, volumetype="SAS" ) loginSpec = Login( ssh_key="KeyPair-001" ) specbody = NodeSpec( flavor="c7.large.2", az="******", os="EulerOS 2.5", login=loginSpec, root_volume=rootVolumeSpec, data_volumes=listDataVolumesSpec, storage=storageSpec, node_nic_spec=nodeNicSpecSpec, count=1, billing_mode=1, runtime=runtimeSpec, extend_param=extendParamSpec ) metadatabody = NodeMetadata( name="test-67235" ) request.body = NodeCreateRequest( spec=specbody, metadata=metadatabody, api_version="v3", kind="Node" ) response = client.create_node(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
Create a pay-per-use node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateNodeRequest() request.cluster_id = "{cluster_id}" extendParamSpec = NodeExtendParam( max_pods=110 ) runtimeSpec = Runtime( name="docker" ) primaryNicNodeNicSpec = NicSpec( subnet_id="ca964acf-8468-4735-8229-97940ef6c881" ) nodeNicSpecSpec = NodeNicSpec( primary_nic=primaryNicNodeNicSpec ) listVirtualSpacesStorageGroups = [ VirtualSpace( name="runtime", size="90%" ), VirtualSpace( name="kubernetes", size="10%" ) ] listSelectorNamesStorageGroups = [ "cceUse" ] listStorageGroupsStorage = [ StorageGroups( name="vgpaas", cce_managed=True, selector_names=listSelectorNamesStorageGroups, virtual_spaces=listVirtualSpacesStorageGroups ) ] matchLabelsStorageSelectors = StorageSelectorsMatchLabels( size="100", volume_type="SAS", count="1" ) listStorageSelectorsStorage = [ StorageSelectors( name="cceUse", storage_type="evs", match_labels=matchLabelsStorageSelectors ) ] storageSpec = Storage( storage_selectors=listStorageSelectorsStorage, storage_groups=listStorageGroupsStorage ) listDataVolumesSpec = [ Volume( size=100, volumetype="SAS" ) ] rootVolumeSpec = Volume( size=50, volumetype="SAS" ) loginSpec = Login( ssh_key="KeyPair-001" ) specbody = NodeSpec( flavor="c7.large.2", az="******", os="EulerOS 2.5", login=loginSpec, root_volume=rootVolumeSpec, data_volumes=listDataVolumesSpec, storage=storageSpec, node_nic_spec=nodeNicSpecSpec, count=1, billing_mode=0, runtime=runtimeSpec, extend_param=extendParamSpec ) metadatabody = NodeMetadata( name="test-83790" ) request.body = NodeCreateRequest( spec=specbody, metadata=metadatabody, api_version="v3", kind="Node" ) response = client.create_node(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
Create a pay-per-usenode with the flavor of 2 vCPUs and 4 GiB of memory. The node runs Huawei Cloud EulerOS 2.0 and uses Docker. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. The data disk uses the shared disk space mode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkcce.v3.region.cce_region import CceRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkcce.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = CreateNodeRequest() request.cluster_id = "{cluster_id}" extendParamSpec = NodeExtendParam( max_pods=110 ) runtimeSpec = Runtime( name="docker" ) primaryNicNodeNicSpec = NicSpec( subnet_id="ca964acf-8468-4735-8229-97940ef6c881" ) nodeNicSpecSpec = NodeNicSpec( primary_nic=primaryNicNodeNicSpec ) listVirtualSpacesStorageGroups = [ VirtualSpace( name="share", size="100%" ) ] listSelectorNamesStorageGroups = [ "cceUse" ] listStorageGroupsStorage = [ StorageGroups( name="vgpaas", cce_managed=True, selector_names=listSelectorNamesStorageGroups, virtual_spaces=listVirtualSpacesStorageGroups ) ] matchLabelsStorageSelectors = StorageSelectorsMatchLabels( size="100", volume_type="SAS", count="1" ) listStorageSelectorsStorage = [ StorageSelectors( name="cceUse", storage_type="evs", match_labels=matchLabelsStorageSelectors ) ] storageSpec = Storage( storage_selectors=listStorageSelectorsStorage, storage_groups=listStorageGroupsStorage ) listDataVolumesSpec = [ Volume( size=100, volumetype="SAS" ) ] rootVolumeSpec = Volume( size=50, volumetype="SAS" ) loginSpec = Login( ssh_key="KeyPair-001" ) specbody = NodeSpec( flavor="c7.large.2", az="******", os="Huawei Cloud EulerOS 2.0", login=loginSpec, root_volume=rootVolumeSpec, data_volumes=listDataVolumesSpec, storage=storageSpec, node_nic_spec=nodeNicSpecSpec, count=1, billing_mode=0, runtime=runtimeSpec, extend_param=extendParamSpec ) metadatabody = NodeMetadata( name="test-66909" ) request.body = NodeCreateRequest( spec=specbody, metadata=metadatabody, api_version="v3", kind="Node" ) response = client.create_node(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
Create a yearly/monthly node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := cce.NewCceClient( cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateNodeRequest{} request.ClusterId = "{cluster_id}" maxPodsExtendParam:= int32(110) periodTypeExtendParam:= "month" periodNumExtendParam:= int32(1) isAutoRenewExtendParam:= "false" isAutoPayExtendParam:= "false" extendParamSpec := &model.NodeExtendParam{ MaxPods: &maxPodsExtendParam, PeriodType: &periodTypeExtendParam, PeriodNum: &periodNumExtendParam, IsAutoRenew: &isAutoRenewExtendParam, IsAutoPay: &isAutoPayExtendParam, } nameRuntime:= model.GetRuntimeNameEnum().DOCKER runtimeSpec := &model.Runtime{ Name: &nameRuntime, } subnetIdPrimaryNic:= "ca964acf-8468-4735-8229-97940ef6c881" primaryNicNodeNicSpec := &model.NicSpec{ SubnetId: &subnetIdPrimaryNic, } nodeNicSpecSpec := &model.NodeNicSpec{ PrimaryNic: primaryNicNodeNicSpec, } var listVirtualSpacesStorageGroups = []model.VirtualSpace{ { Name: "runtime", Size: "90%", }, { Name: "kubernetes", Size: "10%", }, } var listSelectorNamesStorageGroups = []string{ "cceUse", } cceManagedStorageGroups:= true var listStorageGroupsStorage = []model.StorageGroups{ { Name: "vgpaas", CceManaged: &cceManagedStorageGroups, SelectorNames: listSelectorNamesStorageGroups, VirtualSpaces: listVirtualSpacesStorageGroups, }, } sizeMatchLabels:= "100" volumeTypeMatchLabels:= "SAS" countMatchLabels:= "1" matchLabelsStorageSelectors := &model.StorageSelectorsMatchLabels{ Size: &sizeMatchLabels, VolumeType: &volumeTypeMatchLabels, Count: &countMatchLabels, } var listStorageSelectorsStorage = []model.StorageSelectors{ { Name: "cceUse", StorageType: "evs", MatchLabels: matchLabelsStorageSelectors, }, } storageSpec := &model.Storage{ StorageSelectors: listStorageSelectorsStorage, StorageGroups: listStorageGroupsStorage, } var listDataVolumesSpec = []model.Volume{ { Size: int32(100), Volumetype: "SAS", }, } rootVolumeSpec := &model.Volume{ Size: int32(50), Volumetype: "SAS", } sshKeyLogin:= "KeyPair-001" loginSpec := &model.Login{ SshKey: &sshKeyLogin, } osSpec:= "EulerOS 2.5" countSpec:= int32(1) billingModeSpec:= int32(1) specbody := &model.NodeSpec{ Flavor: "c7.large.2", Az: "******", Os: &osSpec, Login: loginSpec, RootVolume: rootVolumeSpec, DataVolumes: listDataVolumesSpec, Storage: storageSpec, NodeNicSpec: nodeNicSpecSpec, Count: &countSpec, BillingMode: &billingModeSpec, Runtime: runtimeSpec, ExtendParam: extendParamSpec, } nameMetadata:= "test-67235" metadatabody := &model.NodeMetadata{ Name: &nameMetadata, } request.Body = &model.NodeCreateRequest{ Spec: specbody, Metadata: metadatabody, ApiVersion: "v3", Kind: "Node", } response, err := client.CreateNode(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
Create a pay-per-use node with the flavor of 2 vCPUs and 4 GiB of memory. The node runs EulerOS 2.5 for Docker containers. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. Both the disks are of the high I/O type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := cce.NewCceClient( cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateNodeRequest{} request.ClusterId = "{cluster_id}" maxPodsExtendParam:= int32(110) extendParamSpec := &model.NodeExtendParam{ MaxPods: &maxPodsExtendParam, } nameRuntime:= model.GetRuntimeNameEnum().DOCKER runtimeSpec := &model.Runtime{ Name: &nameRuntime, } subnetIdPrimaryNic:= "ca964acf-8468-4735-8229-97940ef6c881" primaryNicNodeNicSpec := &model.NicSpec{ SubnetId: &subnetIdPrimaryNic, } nodeNicSpecSpec := &model.NodeNicSpec{ PrimaryNic: primaryNicNodeNicSpec, } var listVirtualSpacesStorageGroups = []model.VirtualSpace{ { Name: "runtime", Size: "90%", }, { Name: "kubernetes", Size: "10%", }, } var listSelectorNamesStorageGroups = []string{ "cceUse", } cceManagedStorageGroups:= true var listStorageGroupsStorage = []model.StorageGroups{ { Name: "vgpaas", CceManaged: &cceManagedStorageGroups, SelectorNames: listSelectorNamesStorageGroups, VirtualSpaces: listVirtualSpacesStorageGroups, }, } sizeMatchLabels:= "100" volumeTypeMatchLabels:= "SAS" countMatchLabels:= "1" matchLabelsStorageSelectors := &model.StorageSelectorsMatchLabels{ Size: &sizeMatchLabels, VolumeType: &volumeTypeMatchLabels, Count: &countMatchLabels, } var listStorageSelectorsStorage = []model.StorageSelectors{ { Name: "cceUse", StorageType: "evs", MatchLabels: matchLabelsStorageSelectors, }, } storageSpec := &model.Storage{ StorageSelectors: listStorageSelectorsStorage, StorageGroups: listStorageGroupsStorage, } var listDataVolumesSpec = []model.Volume{ { Size: int32(100), Volumetype: "SAS", }, } rootVolumeSpec := &model.Volume{ Size: int32(50), Volumetype: "SAS", } sshKeyLogin:= "KeyPair-001" loginSpec := &model.Login{ SshKey: &sshKeyLogin, } osSpec:= "EulerOS 2.5" countSpec:= int32(1) billingModeSpec:= int32(0) specbody := &model.NodeSpec{ Flavor: "c7.large.2", Az: "******", Os: &osSpec, Login: loginSpec, RootVolume: rootVolumeSpec, DataVolumes: listDataVolumesSpec, Storage: storageSpec, NodeNicSpec: nodeNicSpecSpec, Count: &countSpec, BillingMode: &billingModeSpec, Runtime: runtimeSpec, ExtendParam: extendParamSpec, } nameMetadata:= "test-83790" metadatabody := &model.NodeMetadata{ Name: &nameMetadata, } request.Body = &model.NodeCreateRequest{ Spec: specbody, Metadata: metadatabody, ApiVersion: "v3", Kind: "Node", } response, err := client.CreateNode(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
Create a pay-per-usenode with the flavor of 2 vCPUs and 4 GiB of memory. The node runs Huawei Cloud EulerOS 2.0 and uses Docker. The sizes of the system disk and data disk of the node are 50 GB and 100 GB, respectively. The data disk uses the shared disk space mode.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := cce.NewCceClient( cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.CreateNodeRequest{} request.ClusterId = "{cluster_id}" maxPodsExtendParam:= int32(110) extendParamSpec := &model.NodeExtendParam{ MaxPods: &maxPodsExtendParam, } nameRuntime:= model.GetRuntimeNameEnum().DOCKER runtimeSpec := &model.Runtime{ Name: &nameRuntime, } subnetIdPrimaryNic:= "ca964acf-8468-4735-8229-97940ef6c881" primaryNicNodeNicSpec := &model.NicSpec{ SubnetId: &subnetIdPrimaryNic, } nodeNicSpecSpec := &model.NodeNicSpec{ PrimaryNic: primaryNicNodeNicSpec, } var listVirtualSpacesStorageGroups = []model.VirtualSpace{ { Name: "share", Size: "100%", }, } var listSelectorNamesStorageGroups = []string{ "cceUse", } cceManagedStorageGroups:= true var listStorageGroupsStorage = []model.StorageGroups{ { Name: "vgpaas", CceManaged: &cceManagedStorageGroups, SelectorNames: listSelectorNamesStorageGroups, VirtualSpaces: listVirtualSpacesStorageGroups, }, } sizeMatchLabels:= "100" volumeTypeMatchLabels:= "SAS" countMatchLabels:= "1" matchLabelsStorageSelectors := &model.StorageSelectorsMatchLabels{ Size: &sizeMatchLabels, VolumeType: &volumeTypeMatchLabels, Count: &countMatchLabels, } var listStorageSelectorsStorage = []model.StorageSelectors{ { Name: "cceUse", StorageType: "evs", MatchLabels: matchLabelsStorageSelectors, }, } storageSpec := &model.Storage{ StorageSelectors: listStorageSelectorsStorage, StorageGroups: listStorageGroupsStorage, } var listDataVolumesSpec = []model.Volume{ { Size: int32(100), Volumetype: "SAS", }, } rootVolumeSpec := &model.Volume{ Size: int32(50), Volumetype: "SAS", } sshKeyLogin:= "KeyPair-001" loginSpec := &model.Login{ SshKey: &sshKeyLogin, } osSpec:= "Huawei Cloud EulerOS 2.0" countSpec:= int32(1) billingModeSpec:= int32(0) specbody := &model.NodeSpec{ Flavor: "c7.large.2", Az: "******", Os: &osSpec, Login: loginSpec, RootVolume: rootVolumeSpec, DataVolumes: listDataVolumesSpec, Storage: storageSpec, NodeNicSpec: nodeNicSpecSpec, Count: &countSpec, BillingMode: &billingModeSpec, Runtime: runtimeSpec, ExtendParam: extendParamSpec, } nameMetadata:= "test-66909" metadatabody := &model.NodeMetadata{ Name: &nameMetadata, } request.Body = &model.NodeCreateRequest{ Spec: specbody, Metadata: metadatabody, ApiVersion: "v3", Kind: "Node", } response, err := client.CreateNode(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
Status Code |
Description |
---|---|
201 |
The job for creating a node in a specified cluster is successfully delivered. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot