Updating a Cluster
Function
This API is used to update a cluster.
The URL for cluster management is in the format of https://Endpoint/uri, where uri specifies the resource path for API access.
Calling Method
For details, see Calling APIs.
URI
PUT /autopilot/v3/projects/{project_id}/clusters/{cluster_id}
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. |
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 |
---|---|---|---|
spec |
Yes |
Detailed cluster parameters |
|
metadata |
No |
Basic cluster information, including name-related fields |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
description |
No |
String |
Description of a cluster.
|
customSan |
No |
AutopilotCustomSan object |
The custom SAN field in the API server certificate of a cluster. It complies with the format specifications defined by the SSL standard X509. It is not supported by Autopilot clusters.
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 |
eniNetwork |
No |
AutopilotEniNetworkUpdate object |
Cloud native 2.0 network settings, including the container subnet information of a cluster |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
[items] |
No |
Array of strings |
The custom SAN field in the API server certificate of a cluster. It complies with the format specifications defined by the SSL standard X509. It is not supported by Autopilot clusters.
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 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnets |
No |
Array of AutopilotNetworkSubnet objects |
List of IPv4 subnet IDs. Only new subnets can be added to the list. Existing subnets in the list cannot be deleted. Exercise caution when selecting a new subnet. The request body must contain all existing subnets. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
subnetID |
Yes |
String |
Specifies the IPv4 subnet ID of the subnet used to create control nodes and containers. (IPv6 is not supported.) To obtain the subnet ID, use either of the following methods:
For details, see Querying Subnets. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
alias |
No |
String |
Alias of a cluster name. Enter 4 to 128 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, 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 |
API type. The value is fixed at Cluster or cluster and cannot be changed. |
apiVersion |
String |
API version. The value is fixed at v3 and cannot be changed. |
metadata |
AutopilotClusterMetadata object |
Basic information about a cluster. Metadata is a collection of attributes. |
spec |
AutopilotClusterSpec object |
Element type of the collection class. The main part of a cluster object to be managed is in spec. CCE creates or updates objects by defining or updating spec. |
status |
AutopilotClusterStatus object |
Element type of the collection class, which is used to record the statuses of an object in the system, including the cluster status and the ID of the cluster creation job |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Cluster name. Enter 4 to 128 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. |
uid |
String |
Cluster ID, which uniquely identifies a resource. The value is automatically generated after the object is created. A custom value will not take effect. When you create a yearly/monthly cluster, no cluster ID will be returned in the response body. |
alias |
String |
Alias of a cluster name displayed on the CCE console, and the name can be changed. Enter 4 to 128 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed. A cluster alias must be unique. In the request body for creating or updating a cluster, if the cluster alias is not specified or is left blank, the alias of the cluster is the same as the cluster name. In the response body for creating a cluster, if the cluster alias is not configured, the cluster alias will not be returned. |
annotations |
Map<String,String> |
Cluster annotations in the format of key-value pairs. "annotations": { "key1" : "value1", "key2" : "value2" }
NOTE:
|
labels |
Map<String,String> |
Cluster labels in the format of key-value pairs.
NOTE:
The value of this field is automatically generated by the system and is used by the frontend to identify the features supported by a cluster during the upgrade. Customized values are invalid. |
creationTimestamp |
String |
Time when a cluster was created |
updateTimestamp |
String |
Time when a cluster was updated |
Parameter |
Type |
Description |
---|---|---|
category |
String |
Cluster type. Only Turbo is supported. |
type |
String |
Master node architecture.
|
flavor |
String |
Cluster specifications: cce.autopilot.cluster |
version |
String |
Version of a cluster, which mirrors the baseline version of the Kubernetes community. The latest version is recommended. You can create clusters of the latest three versions on the CCE console. To learn which cluster versions are available, log in to the CCE console, create a cluster, and check supported cluster versions. 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.
NOTE:
|
platformVersion |
String |
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. This parameter cannot be customized, and when you create a cluster, the latest corresponding platform version is selected automatically. The format of platformVersion is cce.X.Y.
|
description |
String |
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. Only UTF-8 encoding is supported. |
customSan |
AutopilotCustomSan object |
The custom SAN field in the API server certificate of a cluster. It complies with the format specifications defined by the SSL standard X509. It is not supported by Autopilot clusters.
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 |
enableSnat |
Boolean |
Whether SNAT is configured for a cluster. This parameter is used and returned only by the Autopilot cluster creation API. After this function is enabled, the cluster can access the Internet through a NAT gateway. By default, the existing NAT gateway in the selected VPC is used. Otherwise, the system automatically creates a NAT gateway of the default specifications, binds an EIP to the NAT gateway, and configures SNAT rules. |
enableSWRImageAccess |
Boolean |
Whether a cluster is interconnected with SWR. This parameter is used and returned only by the Autopilot cluster creation API. To ensure that your cluster nodes can pull images from SWR, the existing SWR and OBS endpoints in the selected VPC are used by default. If not, new SWR and OBS endpoints will be automatically created. |
enableAutopilot |
Boolean |
Whether the cluster is an Autopilot cluster |
ipv6enable |
Boolean |
Whether a cluster uses the IPv6 mode. This parameter is not supported by Autopilot clusters. |
hostNetwork |
AutopilotHostNetwork object |
Node networking parameters, including VPC and subnet ID. This field is mandatory because nodes in a cluster communicate with each other using a VPC. |
containerNetwork |
AutopilotContainerNetwork object |
Container networking parameters, including the container network model and container CIDR block |
eniNetwork |
AutopilotEniNetwork object |
Cloud Native 2.0 network settings |
serviceNetwork |
AutopilotServiceNetwork object |
Service CIDR block, including IPv4 CIDR block |
authentication |
AutopilotAuthentication object |
Configurations of the cluster authentication mode |
billingMode |
Integer |
Cluster billing mode
This parameter defaults to pay-per-use. |
kubernetesSvcIpRange |
String |
Service CIDR block or the IP address range which the kubernetes clusterIP must fall within. If this parameter is not specified during cluster creation, the default value 10.247.0.0/16 is used. This parameter is being deprecated, so you can use serviceNetwork instead. The new field contains the IPv4 CIDR blocks. |
clusterTags |
Array of AutopilotResourceTag objects |
Cluster resource tags |
kubeProxyMode |
String |
Service forwarding mode.
NOTE:
iptables is used by default. |
az |
String |
AZ. This field is returned only for a query. For details about AZs supported by CCE, see Regions and Endpoints. |
extendParam |
AutopilotClusterExtendParam object |
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 |
configurationsOverride |
Array of AutopilotPackageConfiguration objects |
Overrides the default component configurations in a cluster. It is not supported in CCE Autopilot clusters. |
Parameter |
Type |
Description |
---|---|---|
[items] |
Array of strings |
The custom SAN field in the API server certificate of a cluster. It complies with the format specifications defined by the SSL standard X509. It is not supported by Autopilot clusters.
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 |
Parameter |
Type |
Description |
---|---|---|
vpc |
String |
ID of the VPC used to create a master node. Obtain the value using either of the following methods:
|
subnet |
String |
Network ID of the subnet used to create a master node. Obtain the value using either of the following methods:
|
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Container network type
|
Parameter |
Type |
Description |
---|---|---|
subnets |
Array of AutopilotNetworkSubnet objects |
IPv4 subnet ID list of the subnet where an ENI resides. Obtain the value using either of the following methods:
|
Parameter |
Type |
Description |
---|---|---|
subnetID |
String |
Specifies the IPv4 subnet ID of the subnet used to create control nodes and containers. (IPv6 is not supported.) To obtain the subnet ID, use either of the following methods:
For details, see Querying Subnets. |
Parameter |
Type |
Description |
---|---|---|
IPv4CIDR |
String |
Value range of the Kubernetes clusterIP IPv4 CIDR block. If this parameter is not specified during cluster creation, the default value 10.247.0.0/16 is used. |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Cluster authentication mode. The default value is rbac. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Key.
|
value |
String |
Value.
|
Parameter |
Type |
Description |
---|---|---|
enterpriseProjectId |
String |
ID of the enterprise project that a cluster belongs to
NOTE:
|
upgradefrom |
String |
Records of how a cluster is upgraded to its current version |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Component name |
configurations |
Array of AutopilotConfigurationItem objects |
Component configuration items |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Component configuration item name |
value |
Object |
Component configuration item value |
Parameter |
Type |
Description |
---|---|---|
phase |
String |
Cluster status. Options:
|
jobID |
String |
ID of the task associated with the current cluster status. Options:
NOTE:
Tasks are short-lived. Do not use task information in scenarios such as cluster status determination. |
reason |
String |
Why a cluster changes to the current state. This parameter is returned if the cluster is not in the Available state. |
message |
String |
Detailed information about why a cluster changes to the current state. This parameter is returned if the cluster is not in the Available state. |
endpoints |
Array of AutopilotClusterEndpoints objects |
Access address of kube-apiserver in a cluster |
isLocked |
Boolean |
CBC resource locked |
lockScene |
String |
Scenario where the CBC resource is locked |
lockSource |
String |
Resource locked |
lockSourceId |
String |
ID of a locked resource |
deleteOption |
Object |
Status of the configuration to be deleted. This parameter is contained only in the response to the deletion request. |
deleteStatus |
Object |
Information of the status to be deleted. This parameter is contained only in the response to the deletion request. |
Example Requests
Update the description of a cluster.
{ "spec" : { "description" : "new description" } }
Example Responses
Status code: 200
The cluster is updated.
{ "kind" : "Cluster", "apiVersion" : "v3", "metadata" : { "name" : "s00842745-128-3-r0", "uid" : "c82a7d44-1cc4-11ef-8460-0255ac101780", "creationTimestamp" : "2024-05-28 07:34:56.917029 +0000 UTC", "updateTimestamp" : "2024-06-04 13:12:35.749294 +0000 UTC", "labels" : { "FeatureGates" : "arpOptimization,elbv3,xGPU" }, "annotations" : { "enableAutopilot" : "true", "feature:supportNodePoolScaleGroup" : "true" }, "alias" : "s00842745-128-3-r0" }, "spec" : { "category" : "Turbo", "type" : "VirtualMachine", "flavor" : "cce.autopilot.cluster", "version" : "v1.28", "platformVersion" : "cce.3.0", "description" : "new description", "hostNetwork" : { "vpc" : "f9122377-7b2e-49c9-ab9e-bf0bfdd807b4", "subnet" : "6b757878-c428-4e76-a7e9-5e3853778d5d" }, "containerNetwork" : { "mode" : "eni" }, "eniNetwork" : { "eniSubnetId" : "b04a4b46-9f99-44a1-9a98-de52e549e68b", "subnets" : [ { "subnetID" : "b04a4b46-9f99-44a1-9a98-de52e549e68b" } ] }, "serviceNetwork" : { "IPv4CIDR" : "10.247.0.0/16" }, "authentication" : { "mode" : "rbac" }, "billingMode" : 0, "kubernetesSvcIpRange" : "10.247.0.0/16", "kubeProxyMode" : "iptables", "az" : "cn-north-7c", "extendParam" : { "enterpriseProjectId" : "5ebc44c1-617b-4d93-8d49-895b8a457a1f", "upgradefrom" : "" } }, "status" : { "phase" : "Available", "endpoints" : [ { "url" : "https://c82a7d44-1cc4-11ef-8460-0255ac101780.cluster.cce.cn-north-7.myhuaweicloud.com:5443", "type" : "Internal" } ] } }
SDK Sample Code
The SDK sample code is as follows.
Update 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 UpdateAutopilotClusterSolution { 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(); UpdateAutopilotClusterRequest request = new UpdateAutopilotClusterRequest(); request.withClusterId("{cluster_id}"); AutopilotClusterInformation body = new AutopilotClusterInformation(); AutopilotClusterInformationSpec specbody = new AutopilotClusterInformationSpec(); specbody.withDescription("new description"); body.withSpec(specbody); request.withBody(body); try { UpdateAutopilotClusterResponse response = client.updateAutopilotCluster(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()); } } } |
Update 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 = UpdateAutopilotClusterRequest() request.cluster_id = "{cluster_id}" specbody = AutopilotClusterInformationSpec( description="new description" ) request.body = AutopilotClusterInformation( spec=specbody ) response = client.update_autopilot_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) |
Update 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.UpdateAutopilotClusterRequest{} request.ClusterId = "{cluster_id}" descriptionSpec:= "new description" specbody := &model.AutopilotClusterInformationSpec{ Description: &descriptionSpec, } request.Body = &model.AutopilotClusterInformation{ Spec: specbody, } response, err := client.UpdateAutopilotCluster(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 |
The cluster is 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