Updating a Specified Cluster
Function
This API is used to update information about a specified cluster.
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.
Calling Method
For details, see Calling APIs.
URI
PUT /api/v3/projects/{project_id}/clusters/{cluster_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Details: Project ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI. Constraints: None Options: Project IDs of the account Default value: N/A |
cluster_id |
Yes |
String |
Details: Cluster ID. For details about how to obtain the value, see How to Obtain Parameters in the API URI. Constraints: None Options: Cluster IDs Default value: N/A |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Details: Request body type or format Constraints: The GET method is not verified. Options:
Default value: N/A |
X-Auth-Token |
Yes |
String |
Details: 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. Constraints: None Options: N/A Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
spec |
Yes |
ClusterInformationSpec object |
Detailed cluster parameters |
metadata |
No |
ClusterMetadataForUpdate object |
Basic cluster information, including name-related fields |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
description |
No |
String |
Cluster description.
|
customSan |
No |
Array of strings |
Details: Custom Subject Alternative Name (SAN) in the server certificate of a cluster API server, which must comply with the SSL and X509 standard formats Constraints: Duplicate names are not allowed. Options: Values in the IP address or domain name format Default value: N/A Example: SAN 1: DNS Name=example.com SAN 2: DNS Name=www.example.com SAN 3: DNS Name=example.net SAN 4: IP Address=93.184.216.34 |
containerNetwork |
No |
ContainerNetworkUpdate object |
Container networking parameters, including information about the container CIDR block. |
eniNetwork |
No |
EniNetworkUpdate object |
Cloud Native Network 2.0 network configuration, including the container subnet information of the CCE Turbo cluster. |
hostNetwork |
No |
hostNetwork object |
Node network parameters, including the default security group settings. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
cidrs |
No |
Array of ContainerCIDR objects |
List of container CIDR blocks. For a clusters of v1.21 or later, if it uses a VPC network, a maximum of 20 container CIDR blocks can be added incrementally. The configuration cannot be modified after the cluster is updated. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
cidr |
Yes |
String |
Details: Container CIDR block. 10.0.0.0/12-19, 172.16.0.0/16-19, or 192.168.0.0/16-19 is recommended. Constraints: If a CIDR block conflict occurs, an error will be reported. Options: N/A Default value: N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnets |
No |
Array of NetworkSubnet objects |
List of IPv4 subnet IDs. CCE Turbo clusters of version 1.19.10 or later support multiple container subnets and allow for incremental updates to the subnet list. The request body must contain all existing subnets. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnetID |
Yes |
String |
Details: IPv4 subnet ID of the subnet used to create a master node Constraints: IPv6 is not supported. Options: N/A Default value: N/A You can obtain the value in either of the following ways:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
SecurityGroup |
No |
String |
The default security group of the worker node in the cluster needs to allow traffic through some ports to ensure normal communication. For details, see How Do I Harden the Automatically Created Security Group Rules for CCE Cluster Nodes. The modified security group applies only to nodes newly created or accepted. For existing nodes, you need to manually modify the security group rules for them. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
alias |
No |
String |
Alias of a cluster name. Enter 4 to 128 characters not starting or ending with a hyphen (-). Only digits, letters, and hyphens (-) are allowed. A cluster alias must be unique. If this parameter is left blank, the alias is not changed. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
kind |
String |
Details: API type Constraints: The value cannot be changed. Options:
Default value: N/A |
apiVersion |
String |
Details: API version Constraints: The value cannot be changed. Options:
Default value: N/A |
metadata |
ClusterMetadata object |
Details: Basic information about a cluster. Metadata is a collection of attributes. Constraints: None |
spec |
ClusterSpec object |
Details: Detailed description of a cluster. CCE creates or updates objects by defining or updating spec. Constraints: None |
status |
ClusterStatus object |
Details: Cluster status and ID of a cluster deletion job Constraints: None |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Details: Cluster name Constraints: None Options: Enter 4 to 128 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. Default value: N/A |
uid |
String |
Details: Cluster ID, which identifies a cluster Constraints: The value is automatically generated after the object is created. A user-defined value will not take effect. When you create a yearly/monthly cluster, no cluster ID will be returned in the response body. Options: N/A Default value: N/A |
alias |
String |
Details: Alias of a cluster name displayed on the CCE console. The name can be changed. A cluster alias must be unique. Constraints: In the request body for creating or updating a cluster, if the cluster alias is not specified or set to null, the cluster name will be used as the cluster alias. In the response body for creating a cluster or other response bodies, if the cluster alias is not configured, no value will be returned. Options: Enter 4 to 128 characters starting with a letter and not starting or ending with a hyphen (-). Only digits, letters, and hyphens (-) are allowed. Default value: N/A |
annotations |
Map<String,String> |
Details: Cluster annotations, in the format of key-value pairs "annotations": { "key1" : "value1", "key2" : "value2" } Constraints: This field is not stored in the database and is used only to specify the add-ons to be installed in the cluster. Options: N/A Default value: N/A
NOTE:
|
labels |
Map<String,String> |
Details: Cluster labels, in the format of key-value pairs Constraints: The value of this field is automatically generated by the system and is used by the frontend to identify the features supported by the cluster during the upgrade. Custom values are invalid. Options: N/A Default value: N/A |
creationTimestamp |
String |
Details: Time when a cluster was created Constraints: None Options: N/A Default value: N/A |
updateTimestamp |
String |
Details: Time when a cluster was updated Constraints: None Options: N/A Default value: N/A |
timezone |
String |
Details: Cluster time zone Constraints: None Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
category |
String |
Details: Cluster type Constraints: None Options:
Default value: CCE when the container network is not set to eni Turbo when the container network is set to eni |
type |
String |
Details: Master node architecture Constraints: None Options:
Default value: VirtualMachine |
flavor |
String |
Details: Cluster specifications. Specifications of clusters v1.15 and later versions can be changed after they are created. For details, see Changing Cluster Scale. Configure this parameter based on actual service requirements. Constraints: None Options:
Default value: N/A
NOTE:
The fields in the parameters are described as follows:
|
version |
String |
Details: Version of a cluster, which mirrors the baseline version of the Kubernetes community. The latest version is recommended. You can create clusters of three latest versions on the CCE console. To learn which cluster versions are available, log in to the CCE console, create a cluster, and check the Cluster Version parameter. You can call APIs to create clusters of other versions. However, these cluster versions will be gradually terminated. For details about the support policy, see the CCE announcement. Constraints: None Options: N/A Default value:
NOTE:
|
platformVersion |
String |
Details: CCE cluster platform version, which is an internal version under the cluster version (version). Platform versions are used to trace iterations in a major cluster version. They are unique within a major cluster version and recounted when the major cluster version changes. Constraints: This parameter cannot be customized, and when you create a cluster, the latest corresponding platform version is selected automatically. Options: The format of platformVersion is cce.X.Y.
Default value: N/A |
legacyVersion |
String |
Details: (Discarded) Outdated version of CCE clusters, which serves no practical purpose and is only used to showcase the cluster version and platform version combination. The version number is globally unique. For example, if the cluster version is va.b and the platformVersion is cce.X.Y, the value of legacyVersion is va.b.X-rY. Constraints: None Options: N/A Default value: N/A |
description |
String |
Details: Cluster description, for example, which purpose the cluster is intended to serve. By default, this field is left blank. To modify cluster description after a cluster is created, call the API for updating a specified cluster or go to the cluster details page on the CCE console. Constraints: Only UTF-8 encoding is supported. Options: N/A Default value: N/A |
customSan |
Array of strings |
Details: Custom Subject Alternative Name (SAN) in the server certificate of a cluster API server, which must comply with the SSL and X509 standard formats Constraints: Duplicate names are not allowed. Options: Values in the IP address or domain name format Default value: N/A Example: SAN 1: DNS Name=example.com SAN 2: DNS Name=www.example.com SAN 3: DNS Name=example.net SAN 4: IP Address=93.184.216.34 |
ipv6enable |
Boolean |
Details: Whether a cluster supports IPv6 addresses. It is supported by clusters v1.15 and later. Constraints: After IPv6 is enabled, iptables is not supported. The VPC network model does not support IPv4/IPv6 dual-stack. Options:
Default value: false |
hostNetwork |
HostNetwork object |
Details: Node network parameters, including VPC and subnet ID. This field is mandatory because nodes in a cluster communicate with each other using a VPC. Constraints: None |
containerNetwork |
ContainerNetwork object |
Details: Container network parameters, including the container network model and container CIDR block Constraints: None |
eniNetwork |
EniNetwork object |
Details: Configuration of the Cloud Native 2.0 network model. You need to specify this field when creating a CCE Turbo cluster. Constraints: None |
serviceNetwork |
ServiceNetwork object |
Details: Service CIDR block, including IPv4 CIDR block Constraints: None |
publicAccess |
PublicAccess object |
Details: Cluster API access control Constraints: None |
authentication |
Authentication object |
Details: Configurations of the cluster authentication mode Constraints: None |
billingMode |
Integer |
Details: Cluster billing mode Constraints: None Options:
Default value: 0 |
masters |
Array of MasterSpec objects |
Details: Advanced configurations of master nodes Constraints: If this parameter is not specified, no value is returned. |
kubernetesSvcIpRange |
String |
Details: Service CIDR blocks which kubernetes clusterIP must fall within. This field is available only for clusters of v1.11.7 and later. If this parameter is not specified during cluster creation, the default value 10.247.0.0/16 is used. This parameter is being discarded, so you can use serviceNetwork instead. The new field contains the IPv4 CIDR blocks. Constraints: None Options: N/A Default value: N/A |
clusterTags |
Array of ResourceTag objects |
Details: Cluster resource tags Constraints: None |
kubeProxyMode |
String |
Details: Service forwarding mode Constraints: None Options:
Default value: iptables is used by default. |
az |
String |
Details: AZ. This field is returned only for a query. For details about AZs supported by CCE, see Regions and Endpoints. Constraints: None |
extendParam |
ClusterExtendParam object |
Details: Extended field to decide whether a cluster will span across AZs or belong to a specified enterprise project, or whether a dedicated CCE cluster is to be created Constraints: None |
supportIstio |
Boolean |
Details: Whether Istio is supported Constraints: None Options:
Default value: true |
enableDistMgt |
Boolean |
Details: Whether to enable support for remote clouds Constraints: Only CCE Turbo clusters support this function. Options:
Default value: false |
configurationsOverride |
Array of PackageConfiguration objects |
Details: Cluster default component configuration override. For details about the supported components and their parameters, see Modifying Cluster Configurations. Constraints: If you specify a component or parameter that is not supported, the configuration item will be ignored. |
clusterOps |
ClusterOps object |
Details: Cluster O&M settings Constraints: None |
enableAutopilot |
Boolean |
Details: Whether the cluster is an Autopilot cluster Constraints: None Options:
Default value: false |
Parameter |
Type |
Description |
---|---|---|
vpc |
String |
Details: ID of the VPC used to create a master node Constraints: None Options: N/A Default value: N/A You can obtain the value in either of the following ways:
|
subnet |
String |
Details: Network ID of the subnet used to create a master node Constraints: None Options: N/A Default value: N/A You can obtain the value in either of the following ways:
|
SecurityGroup |
String |
Details: ID of the default node security group in a cluster Constraints: None Options: N/A Default value:
NOTE:
To ensure proper communication, allow traffic from certain ports to the specified node security group. For details, see How Can I Configure a Security Group Rule in a Cluster? |
controlPlaneSecurityGroup |
String |
Details: ID of the master node security group in a cluster Constraints: The value is automatically generated after the object is created. A user-defined value will not take effect. Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Details: Container network type Constraints: Only one container network type can be selected. Options:
Default value: N/A |
cidr |
String |
Details: Container CIDR block. 10.0.0.0/12-19, 172.16.0.0/16-19, or 192.168.0.0/16-19 is recommended. If the selected CIDR block conflicts with existing ones, an error will be reported. Constraints: This parameter cannot be modified after the cluster is created. (It has been discarded. If cidrs has been configured, the specified CIDR blocks will be ignored.) Once you have created a cluster that uses a VPC network, you can add new CIDR blocks, but you are unable to modify the existing ones. If you need to adjust the CIDR blocks, you will have to create a new cluster. Options: Values in IPv4 CIDR format Default value: If this parameter is left blank, a unique CIDR block is randomly allocated from 172.(16–31).0.0/16 and 10.(0 | 16 | 32 | 48 | 64 | 80 | 96 | 112).0.0/12. |
cidrs |
Array of ContainerCIDR objects |
Details: List of container CIDR blocks. In clusters of v1.21 or later, the cidrs field is used. When the cluster network type is vpc-router, you can configure a maximum of 20 container CIDR blocks. In clusters of versions earlier than v1.21, if the cidrs field is used, the first CIDR element in the array is used as the container CIDR block. Constraints: Once you have created a cluster that uses a container tunnel network, you cannot modify the CIDR blocks. Once you have created a cluster that uses a VPC network, you can add new CIDR blocks, but you are unable to modify the existing ones. If you need to adjust the CIDR blocks, you will have to create a new cluster. |
Parameter |
Type |
Description |
---|---|---|
cidr |
String |
Details: Container CIDR block. 10.0.0.0/12-19, 172.16.0.0/16-19, or 192.168.0.0/16-19 is recommended. Constraints: If a CIDR block conflict occurs, an error will be reported. Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
eniSubnetId |
String |
Details: IPv4 subnet ID list of the subnet where an ENI resides Constraints: IPv6 is not supported. This parameter is being discarded, and the new field subnets is recommended. Options: N/A Default value: N/A You can obtain the value in either of the following ways:
|
eniSubnetCIDR |
String |
Details: ENI subnet CIDR block Constraints: This parameter is being discarded. The new field subnets is recommended. Options: N/A Default value: N/A |
subnets |
Array of NetworkSubnet objects |
Details: List of IPv4 subnet IDs Constraints: None |
Parameter |
Type |
Description |
---|---|---|
subnetID |
String |
Details: IPv4 subnet ID of the subnet used to create a master node Constraints: IPv6 is not supported. Options: N/A Default value: N/A You can obtain the value in either of the following ways:
|
Parameter |
Type |
Description |
---|---|---|
IPv4CIDR |
String |
Details: Value range of the Kubernetes clusterIP IPv4 CIDR block Constraints: None Options: N/A Default value: 10.247.0.0/16 |
IPv6CIDR |
String |
Details: Value range of the Kubernetes clusterIP IPv6 CIDR block Constraints: IPv6 Service CIDR blocks can be configured only for CCE Turbo clusters with IPv6 dual stack enabled. Options: N/A Default value: Default value for a CCE Turbo cluster: fc00::/112 Default value for a CCE standard cluster: fd00:1234::/120 |
Parameter |
Type |
Description |
---|---|---|
cidrs |
Array of strings |
Details: Trustlist of network CIDRs that are allowed to access cluster APIs. You are advised to allow the traffic from VPC and container network CIDRs. Constraints: This parameter is valid only when a cluster is created. Options: N/A Default value: By default, no trustlist is configured, and the value is 0.0.0.0/0. |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Details: Cluster authentication mode Constraints: None Options:
Default value:
|
authenticatingProxy |
AuthenticatingProxy object |
Details: Configuration related to the authenticating_proxy mode Constraints: This field is mandatory when the authentication mode is authenticating_proxy. |
Parameter |
Type |
Description |
---|---|---|
ca |
String |
Details: X509 CA certificate (Base64-encoded) configured in authenticating_proxy mode Constraints: This field is mandatory when the cluster authentication mode is authenticating_proxy. Options: Maximum size: 1 MB Default value: N/A |
cert |
String |
Details: Client certificate issued by the X509 CA certificate configured in authenticating_proxy mode, which is used for authentication from kube-apiserver to the extended API server. (The value must be Base64-encoded.) Constraints: This field is mandatory when the cluster authentication mode is authenticating_proxy. Options: Maximum size: 1 MB Default value: N/A |
privateKey |
String |
Details: Private key of the client certificate issued by the X509 CA certificate configured in authenticating_proxy mode, which is used for authentication from kube-apiserver to the extended API server. The private key used by the Kubernetes cluster does not support password encryption. Use an unencrypted private key. (The value must be Base64-encoded.) Constraints: This field is mandatory when the cluster authentication mode is authenticating_proxy. Options: Maximum size: 1 MB Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
availabilityZone |
String |
Details: AZ Constraints: None Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Details: Key Constraints: None Options:
Default value: N/A |
value |
String |
Details: Value Constraints: None Options:
Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
clusterAZ |
String |
Details: AZs of master nodes in a cluster For details about AZs supported by CCE, see Regions and Endpoints. Constraints: None Options:
Default value: If no AZ is specified, an AZ is randomly allocated by default. |
dssMasterVolumes |
String |
Details: Whether the system and data disks of a master node use dedicated distributed storage. If this parameter is omitted or left unspecified, EVS disks are used by default. Constraints: This parameter is mandatory for dedicated CCE clusters. It is in the following format: <rootVol.dssPoolID>.<rootVol.volType>;<dataVol.dssPoolID>.<dataVol.volType> Specifically:
Example: c950ee97-587c-4f24-8a74-3367e3da570f.sas;6edbc2f4-1507-44f8-ac0d-eed1d2608d38.ssd
NOTE:
This field cannot be configured for non-dedicated CCE clusters. |
enterpriseProjectId |
String |
Details: ID of the enterprise project that a cluster belongs to Constraints: An enterprise project can be configured only after the enterprise project function is enabled. Options: N/A Default value: N/A |
kubeProxyMode |
String |
Details: Service forwarding mode Constraints: This parameter has been discarded. If both this parameter and kubeProxyMode in ClusterSpec are specified, the latter is used. Options:
Default value: iptables |
clusterExternalIP |
String |
Details: EIP of the master node Constraints: None Options: N/A Default value: N/A |
alpha.cce/fixPoolMask |
String |
Details: Number of mask bits of the fixed IP address pool of the container networks. This parameter determines the maximum number of IP addresses that can be assigned to containers on a node. This, along with the maxPods setting during node creation, determines the maximum number of pods that can be created on a node. For details, see Maximum Number of Pods That Can Be Created on a Node. Constraints: Only the vpc-router networks support this function. Options: Integers from 24 to 28 Default value: 24 |
decMasterFlavor |
String |
Details: Master node flavor in a dedicated CCE cluster Constraints: None Options: N/A Default value: N/A |
dockerUmaskMode |
String |
Details: Default UmaskMode configuration of Docker in a cluster Constraints: None Options:
Default value: normal |
kubernetes.io/cpuManagerPolicy |
String |
Details: Cluster CPU management policy Constraints: None Options:
Default value: none |
orderID |
String |
Details: Order ID Constraints: This parameter is returned in the response when the cluster is billed on a yearly/monthly basis with auto payment enabled (only in creation scenarios). Options: N/A Default value: N/A |
periodType |
String |
Details: The subscription term unit Constraints: As a request parameter, it is valid and mandatory when billingMode is set to 1, which is, the yearly/monthly billing mode is configured. As a response parameter, it is returned only when a yearly/monthly cluster is created. Options:
Default value: N/A |
periodNum |
Integer |
Details: Number of subscription periods Constraints: As a request parameter, it is valid and mandatory when billingMode is set to 1. As a response parameter, it is returned only when a yearly/monthly cluster is created. Options:
Default value: N/A |
isAutoRenew |
String |
Details: Whether to enable auto renewal Constraints: This field is valid only when billingMode is set to 1. Options:
Default value: false |
isAutoPay |
String |
Details: Whether to enable auto payment Constraints: This field is valid only when billingMode is set to 1. Options:
Default value: false |
upgradefrom |
String |
Details: Records of how a cluster is upgraded to its current version Constraints: None Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Details: Component name Constraints: None Options: N/A Default value: N/A |
configurations |
Array of ConfigurationItem objects |
Details: Component configuration items Constraints: None |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Details: Component configuration item name Constraints: None Options: N/A Default value: N/A |
value |
Object |
Details: Component configuration item value Constraints: None Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
alarm |
AlarmInfo object |
Details: Alarm assistant settings. CCE is integrated with AOM, which enables alarm functionality, allowing for easy search and configuration of alarms. The Cloud Native Cluster Monitoring add-on sends metric rule data in CCE alarm center to AOM instances. Constraints: None |
Parameter |
Type |
Description |
---|---|---|
topics |
Array of strings |
Details: Contact group list. You can enter SMN topic names and configure contact groups to manage endpoints that have subscribed to alarm messages. Constraints: None |
alarmRuleTemplateId |
String |
Details: Alarm rule template ID transferred when the alarm assistant is enabled. By default, the alarm rule template in the container scenario is used. Constraints: None Options: N/A Default value: N/A |
promInstanceID |
String |
Details: ID of the AOM Prometheus instance transferred when the alarm assistant is enabled. If the Prometheus add-on is not installed or the AOM instance is not connected, there is no need to specify this parameter. In this case, the alarm center will not generate metric alarm rules. Constraints: None Options: N/A Default value: N/A |
promEnterpriseProjectID |
String |
Details: Enterprise project ID of the AOM Prometheus instance transferred when the alarm assistant is enabled. If the Prometheus add-on is not installed or the AOM instance is not connected, there is no need to specify this parameter. In this case, the alarm center will not generate metric alarm rules. Constraints: None Options: N/A Default value: N/A |
Parameter |
Type |
Description |
---|---|---|
phase |
String |
Details: Cluster status Constraints: None Options:
|
jobID |
String |
Details: ID of the job associated with the current cluster status. The system supports:
Constraints: None Options: N/A
NOTE:
Jobs are short-lived. Do not use job information in scenarios such as cluster status determination. |
reason |
String |
Details: Why a cluster changes to the current state. This parameter is returned if the cluster is not in the Available state. Constraints: None Options: N/A |
message |
String |
Details: Detailed information about why a cluster changes to the current state. This parameter is returned if the cluster is not in the Available state. Constraints: None Options: N/A |
endpoints |
Array of ClusterEndpoints objects |
Details: Access address of kube-apiserver in a cluster Constraints: None |
isLocked |
Boolean |
Details: CBC resource locked Constraints: None Options:
|
lockScene |
String |
Details: CBC resource locking scenario Constraints: None Options: N/A |
lockSource |
String |
Details: Resource locked Constraints: None Options: N/A |
lockSourceId |
String |
Details: ID of a locked resource Constraints: None Options: N/A |
deleteOption |
Object |
Details: Status of the configuration to be deleted. This parameter is contained only in the response to the deletion request. Constraints: None Options: N/A |
deleteStatus |
Object |
Details: Information of the status to be deleted. This parameter is contained only in the response to the deletion request. Constraints: None Options: N/A |
Parameter |
Type |
Description |
---|---|---|
url |
String |
Details: Access address of kube-apiserver in a cluster Constraints: None Options: N/A |
type |
String |
Details: Type of the cluster access address Constraints: None Options:
|
Example Requests
-
Updating only the description of a cluster
{ "spec" : { "description" : "new description" } }
-
Updating only the custom SAN of the cluster certificate
{ "spec" : { "customSan" : [ "192.168.1.0", "example.com" ] } }
-
Updating both the cluster description and custom certificate SAN
{ "spec" : { "description" : "new description", "customSan" : [ "192.168.1.0", "example.com" ] } }
-
Configure a CIDR block for a cluster that uses VPCs and is of a version later than v1.21.
{ "spec" : { "containerNetwork" : { "cidrs" : [ { "cidr" : "10.10.0.0/16" }, { "cidr" : "10.11.0.0/16" } ] } } }
-
Modify the default security group of a node in a cluster.
/api/v3/projects/{project_id}/clusters/{cluster_id} { "spec" : { "hostNetwork" : { "SecurityGroup" : "6ee29825-8f49-4796-b33a-fc76f84a59ae" } } }
Example Responses
Status code: 200
Information about the specified cluster is successfully updated.
{ "kind" : "Cluster", "apiVersion" : "v3", "metadata" : { "alias" : "mycluster", "name" : "mycluster", "uid" : "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "creationTimestamp" : "2018-08-02 03:48:58.968214406 +0000 UTC", "updateTimestamp" : "2018-08-02 06:39:36.844676088 +0000 UTC" }, "spec" : { "type" : "VirtualMachine", "flavor" : "cce.s1.small", "version" : "v1.7.3-r13", "description" : "new description", "customSan" : [ "192.168.1.0", "example.com" ], "hostNetwork" : { "vpc" : "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "subnet" : "4d1ecb2c-229a-11e8-9c75-0255ac100ceb", "SecurityGroup" : "6ee29825-8f49-4796-b33a-fc76f84a59ae" }, "containerNetwork" : { "mode" : "overlay_l2", "cidr" : "172.17.0.0/16" }, "authentication" : { "mode" : "x509", "authenticatingProxy" : { } }, "billingMode" : 0 }, "status" : { "phase" : "Available", "endpoints" : [ { "url" : "https://192.168.0.11:5443", "type" : "Internal" } ] } }
SDK Sample Code
The SDK sample code is as follows.
-
Updating only the description of a cluster
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
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.*; public class UpdateClusterSolution { 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(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withDescription("new description"); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(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()); } } }
-
Updating only the custom SAN of the cluster certificate
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
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 java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { 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(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<String> listSpecCustomSan = new ArrayList<>(); listSpecCustomSan.add("192.168.1.0"); listSpecCustomSan.add("example.com"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withCustomSan(listSpecCustomSan); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(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()); } } }
-
Updating both the cluster description and custom certificate SAN
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
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 java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { 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(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<String> listSpecCustomSan = new ArrayList<>(); listSpecCustomSan.add("192.168.1.0"); listSpecCustomSan.add("example.com"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withDescription("new description") .withCustomSan(listSpecCustomSan); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(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()); } } }
-
Configure a CIDR block for a cluster that uses VPCs and is of a version later than v1.21.
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
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 java.util.List; import java.util.ArrayList; public class UpdateClusterSolution { 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(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); List<ContainerCIDR> listContainerNetworkCidrs = new ArrayList<>(); listContainerNetworkCidrs.add( new ContainerCIDR() .withCidr("10.10.0.0/16") ); listContainerNetworkCidrs.add( new ContainerCIDR() .withCidr("10.11.0.0/16") ); ContainerNetworkUpdate containerNetworkSpec = new ContainerNetworkUpdate(); containerNetworkSpec.withCidrs(listContainerNetworkCidrs); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withContainerNetwork(containerNetworkSpec); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(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()); } } }
-
Modify the default security group of a node in a cluster.
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
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.*; public class UpdateClusterSolution { 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(); UpdateClusterRequest request = new UpdateClusterRequest(); request.withClusterId("{cluster_id}"); ClusterInformation body = new ClusterInformation(); ClusterInformationSpecHostNetwork hostNetworkSpec = new ClusterInformationSpecHostNetwork(); hostNetworkSpec.withSecurityGroup("6ee29825-8f49-4796-b33a-fc76f84a59ae"); ClusterInformationSpec specbody = new ClusterInformationSpec(); specbody.withHostNetwork(hostNetworkSpec); body.withSpec(specbody); request.withBody(body); try { UpdateClusterResponse response = client.updateCluster(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()); } } }
-
Updating only the description of a cluster
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
# 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 = UpdateClusterRequest() request.cluster_id = "{cluster_id}" specbody = ClusterInformationSpec( description="new description" ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating only the custom SAN of the cluster certificate
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
# 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 = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCustomSanSpec = [ "192.168.1.0", "example.com" ] specbody = ClusterInformationSpec( custom_san=listCustomSanSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating both the cluster description and custom certificate SAN
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
# 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 = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCustomSanSpec = [ "192.168.1.0", "example.com" ] specbody = ClusterInformationSpec( description="new description", custom_san=listCustomSanSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Configure a CIDR block for a cluster that uses VPCs and is of a version later than v1.21.
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
# 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 = UpdateClusterRequest() request.cluster_id = "{cluster_id}" listCidrsContainerNetwork = [ ContainerCIDR( cidr="10.10.0.0/16" ), ContainerCIDR( cidr="10.11.0.0/16" ) ] containerNetworkSpec = ContainerNetworkUpdate( cidrs=listCidrsContainerNetwork ) specbody = ClusterInformationSpec( container_network=containerNetworkSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Modify the default security group of a node in a cluster.
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
# 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 = UpdateClusterRequest() request.cluster_id = "{cluster_id}" hostNetworkSpec = ClusterInformationSpecHostNetwork( security_group="6ee29825-8f49-4796-b33a-fc76f84a59ae" ) specbody = ClusterInformationSpec( host_network=hostNetworkSpec ) request.body = ClusterInformation( spec=specbody ) response = client.update_cluster(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
-
Updating only the description of a cluster
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
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.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" descriptionSpec:= "new description" specbody := &model.ClusterInformationSpec{ Description: &descriptionSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Updating only the custom SAN of the cluster certificate
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
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.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCustomSanSpec = []string{ "192.168.1.0", "example.com", } specbody := &model.ClusterInformationSpec{ CustomSan: &listCustomSanSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Updating both the cluster description and custom certificate SAN
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
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.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCustomSanSpec = []string{ "192.168.1.0", "example.com", } descriptionSpec:= "new description" specbody := &model.ClusterInformationSpec{ Description: &descriptionSpec, CustomSan: &listCustomSanSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Configure a CIDR block for a cluster that uses VPCs and is of a version later than v1.21.
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
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.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" var listCidrsContainerNetwork = []model.ContainerCidr{ { Cidr: "10.10.0.0/16", }, { Cidr: "10.11.0.0/16", }, } containerNetworkSpec := &model.ContainerNetworkUpdate{ Cidrs: &listCidrsContainerNetwork, } specbody := &model.ClusterInformationSpec{ ContainerNetwork: containerNetworkSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
-
Modify the default security group of a node in a cluster.
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
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.UpdateClusterRequest{} request.ClusterId = "{cluster_id}" securityGroupHostNetwork:= "6ee29825-8f49-4796-b33a-fc76f84a59ae" hostNetworkSpec := &model.ClusterInformationSpecHostNetwork{ SecurityGroup: &securityGroupHostNetwork, } specbody := &model.ClusterInformationSpec{ HostNetwork: hostNetworkSpec, } request.Body = &model.ClusterInformation{ Spec: specbody, } response, err := client.UpdateCluster(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 |
---|---|
200 |
Information about the specified cluster is successfully updated. |
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