Deleting a Cluster
Function
This API is used to delete 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
DELETE /api/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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
delete_efs |
No |
String |
Whether to delete SFS Turbo volumes. Value options:
|
delete_eni |
No |
String |
Whether to delete ENI ports (native elastic network interface). Value options:
|
delete_evs |
No |
String |
Whether to delete EVS disks. Value options:
|
delete_net |
No |
String |
Whether to delete cluster Service and ingress resources, such as ELB load balancers. Value options:
|
delete_obs |
No |
String |
Whether to delete OBS volumes. Value options:
|
delete_sfs |
No |
String |
Whether to delete SFS volumes. Value options:
|
delete_sfs30 |
No |
String |
Whether to delete an SFS 3.0 volume. Example value:
|
lts_reclaim_policy |
No |
String |
Whether to delete an LTS log stream. Options:
|
tobedeleted |
No |
String |
Whether to use the preset deletion mode for yearly/monthly-billed clusters. This parameter is valid only for yearly/monthly-billed clusters. This parameter must be used together with other deletion parameters. You can specify parameter values or the system uses the default ones. If this parameter is used, the cluster does not delete resources. All query parameters of this request will be preset in the cluster database for identifying the resources to be deleted when a yearly/monthly-billed cluster is unsubscribed from. This request can be executed for multiple times. Each request overwrites the deletion parameters preset last time. Value options:
|
ondemand_node_policy |
No |
String |
Policies for processing all pay-per-use nodes in a cluster. Options:
|
periodic_node_policy |
No |
String |
Policies for processing all yearly/monthly nodes in a cluster. Options:
|
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. |
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 |
ClusterMetadata object |
Basic information about a cluster. Metadata is a collection of attributes. |
spec |
ClusterSpec object |
Detailed description of the cluster. CCE creates or updates objects by defining or updating spec. |
status |
ClusterStatus object |
Cluster status and job 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 cluster. This ID is automatically generated after a cluster is created. Only the automatically generated ID will 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 not starting or ending with a hyphen (-). Only digits, letters, 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 obtaining a cluster, the cluster alias is returned. If the cluster alias is not configured, the cluster name is 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 the cluster during the upgrade. Customized values are invalid. |
creationTimestamp |
String |
Time when the cluster was created. |
updateTimestamp |
String |
Time when the cluster was updated. |
Parameter |
Type |
Description |
---|---|---|
category |
String |
Cluster type. Options:
|
type |
String |
Master node architecture:
|
flavor |
String |
Cluster specifications. Specifications of clusters 1.15 or later versions can be changed after they are created. For details, see Modifying Cluster Specifications. Options:
NOTE:
The fields in the parameters are described as follows:
|
version |
String |
Cluster version, which mirrors the baseline version of the Kubernetes community. The latest version is recommended. You can create clusters of two 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.
NOTE:
|
platformVersion |
String |
CCE cluster platform version, indicating the 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. When you create a cluster, the latest corresponding platform version is automatically selected. 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 unspecified. To modify cluster description after the cluster is created, call the API for updating cluster information or go to the cluster details page on the CCE console. Only UTF-8 encoding is supported. |
customSan |
Array of strings |
Custom SAN field in the server certificate of the cluster API server, which must comply with the SSL and X509 format specifications.
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 |
Whether the cluster supports IPv6 addresses. This field is supported in clusters of v1.15 and later versions. |
hostNetwork |
HostNetwork object |
Node networking parameters, including VPC and subnet ID. This field is mandatory because nodes in a cluster communicate with each other by using a VPC. |
containerNetwork |
ContainerNetwork object |
Container networking parameters, including the container network model and container CIDR block. |
eniNetwork |
EniNetwork object |
Configuration of the Cloud Native Network 2.0 model. Specify this field when creating a CCE Turbo cluster. |
serviceNetwork |
ServiceNetwork object |
Service CIDR block, including IPv4 CIDR blocks. |
authentication |
Authentication object |
Configurations of the cluster authentication mode. |
billingMode |
Integer |
Billing mode of a cluster.
Defaults to pay-per-use. |
masters |
Array of MasterSpec objects |
Advanced configurations of master nodes |
kubernetesSvcIpRange |
String |
Service CIDR blocks for Kubernetes clusterIPs. 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 will be used. This parameter is deprecated. Use serviceNetwork instead. The new field contains the IPv4 CIDR blocks. |
clusterTags |
Array of ResourceTag objects |
Cluster resource tags. |
kubeProxyMode |
String |
Service forwarding mode. Options:
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 |
ClusterExtendParam object |
Extended field to decide whether the cluster will span across AZs or belong to a specified enterprise project, or whether a dedicated CCE cluster is to be created. |
supportIstio |
Boolean |
Whether Istio is supported. |
configurationsOverride |
Array of PackageConfiguration objects |
Cluster default component configuration override. If you specify a component or parameter that is not supported, the configuration item will be ignored. For details about the supported components and their parameters, see Cluster Configuration Management. |
Parameter |
Type |
Description |
---|---|---|
vpc |
String |
ID of the VPC used to create a master node. You can obtain it in either of the following ways:
|
subnet |
String |
Network ID of the subnet used to create a master node. You can obtain it in either of the following ways:
|
SecurityGroup |
String |
Default worker node security group ID of the cluster. If specified, the cluster will be bound to the target security group. Otherwise, the system will automatically create a default worker node security group for you. The default worker node security group needs to allow access from certain ports to ensure normal communications. For details, see How Do I Harden the Automatically Created Security Group Rules for CCE Cluster Nodes. |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Container network model. Select one of the following possible values:
|
cidr |
String |
Container CIDR block. Recommended: 10.0.0.0/12-19, 172.16.0.0/16-19, or 192.168.0.0/16-19. If the selected CIDR block conflicts with existing ones, an error will be reported. Not editable after the cluster is created. (deprecated. A specified cidrs will make cidr invalid.) |
cidrs |
Array of ContainerCIDR objects |
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 cluster 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. The configuration cannot be modified after the cluster is created. |
Parameter |
Type |
Description |
---|---|---|
cidr |
String |
Container CIDR block. Recommended: 10.0.0.0/12-19, 172.16.0.0/16-19, and 192.168.0.0/16-19 |
Parameter |
Type |
Description |
---|---|---|
eniSubnetId |
String |
IPv4 subnet ID of ENI subnet. (IPv6 is not supported and is being discarded.) You can obtain it in either of the following ways:
|
eniSubnetCIDR |
String |
ENI subnet CIDR (being discarded) |
subnets |
Array of NetworkSubnet objects |
List of IPv4 subnet IDs |
Parameter |
Type |
Description |
---|---|---|
subnetID |
String |
IPv4 subnet ID of the subnet for creating master nodes. IPv6 is not supported. You can obtain it in either of the following ways:
|
Parameter |
Type |
Description |
---|---|---|
IPv4CIDR |
String |
Value range of the Kubernetes clusterIP IPv4 CIDR blocks. If this parameter is not specified during cluster creation, the default value 10.247.0.0/16 will be used. |
Parameter |
Type |
Description |
---|---|---|
mode |
String |
Cluster authentication mode.
|
authenticatingProxy |
AuthenticatingProxy object |
Configuration related to the authenticating_proxy mode. This field is mandatory when the authentication mode is authenticating_proxy. |
Parameter |
Type |
Description |
---|---|---|
ca |
String |
X509 CA certificate (Base64-encoded) configured in authenticating_proxy mode. This field is mandatory when the cluster authentication mode is authenticating_proxy. Maximum size: 1 MB |
cert |
String |
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.) This field is mandatory when the cluster authentication mode is authenticating_proxy. |
privateKey |
String |
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.) This field is mandatory when the cluster authentication mode is authenticating_proxy. |
Parameter |
Type |
Description |
---|---|---|
key |
String |
Key.
|
value |
String |
Value.
|
Parameter |
Type |
Description |
---|---|---|
clusterAZ |
String |
AZ of master nodes in a cluster. For details about AZs supported by CCE, see Regions and Endpoints.
|
dssMasterVolumes |
String |
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. This parameter is mandatory for dedicated CCE clusters. It is in the following format: <rootVol.dssPoolID>.<rootVol.volType>;<dataVol.dssPoolID>.<dataVol.volType> Field description:
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 |
ID of the enterprise project that a cluster belongs to.
NOTE:
|
kubeProxyMode |
String |
Service forwarding mode. Two modes are available:
NOTE:
This parameter has been deprecated. If this parameter and kubeProxyMode in ClusterSpec are specified at the same time, the latter is used. |
clusterExternalIP |
String |
EIP of the master node |
alpha.cce/fixPoolMask |
String |
Number of mask bits of the fixed IP address pool of the container network model. This field is supported only for the VPC network model (vpc-router). This parameter determines the number of container IP addresses that can be allocated to a node. The maximum number of pods that can be created on a node is decided by this parameter and maxPods set during node creation. For details, see Maximum Number of Pods That Can Be Created on a Node. For integer characters, the value ranges from 24 to 28. |
decMasterFlavor |
String |
Specifications of the master node in the dedicated hybrid cluster. |
dockerUmaskMode |
String |
Default UmaskMode configuration of Docker in a cluster. The value can be secure or normal. If this parameter is not specified, normal is used by default. |
kubernetes.io/cpuManagerPolicy |
String |
Cluster CPU management policy. The value can be none (or null) or static. The default value is none (or null).
|
orderID |
String |
Order ID. 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). |
periodType |
String |
NOTE:
Request parameter, which is valid and mandatory when billingMode is set to 1 (yearly/monthly billing). Response parameter, which is returned only when a yearly/monthly cluster is created. |
periodNum |
Integer |
Subscription duration. The value can be:
NOTE:
Request parameter, which is valid and mandatory when billingMode is set to 1. Response parameter, which is returned only when a yearly/monthly cluster is created. |
isAutoRenew |
String |
Whether auto renewal is enabled.
NOTE:
This field is valid when billingMode is set to 1. 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. If not specified, auto fee deduction is not enabled. |
upgradefrom |
String |
Records of how the cluster is upgraded to the current version |
Parameter |
Type |
Description |
---|---|---|
name |
String |
Component name. |
configurations |
Array of ConfigurationItem objects |
Component configuration item. |
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 cluster in the current state. Options:
NOTE:
Tasks are short-lived. Do not use task information in scenarios such as cluster status determination. |
reason |
String |
Reason of cluster state change. This parameter is returned if the cluster is not in the Available state. |
message |
String |
Detailed information about why the cluster changes to the current state. This parameter is returned if the cluster is not in the Available state. |
endpoints |
Array of ClusterEndpoints objects |
Access address of kube-apiserver in the cluster. |
isLocked |
Boolean |
The CBC resource is locked. |
lockScene |
String |
Scenario where the CBC resource is locked. |
lockSource |
String |
Resource locking. |
lockSourceId |
String |
ID of the locked resource. |
deleteOption |
Object |
Whether to delete configurations. This parameter is contained only in the response to the deletion request. |
deleteStatus |
Object |
Whether to delete the status information. This parameter is contained only in the response to the deletion request. |
Example Requests
None
Example Responses
Status code: 200
The job for deleting a cluster is successfully delivered.
{ "kind" : "Cluster", "apiVersion" : "v3", "metadata" : { "alias" : "mycluster", "name" : "mycluster", "uid" : "fc563b3c-9552-11e8-8beb-0255ac106311", "creationTimestamp" : "2018-08-01 06:20:28.81667161 +0000 UTC", "updateTimestamp" : "2018-08-01 09:23:38.944333282 +0000 UTC" }, "spec" : { "type" : "VirtualMachine", "flavor" : "cce.s1.small", "version" : "v1.7.3-r13", "description" : "new description", "hostNetwork" : { "vpc" : "cbed56e8-03e7-4304-a477-b54bef0857c3", "subnet" : "5de50062-2be2-4a52-893e-e0906e3e9c9d" }, "containerNetwork" : { "mode" : "overlay_l2", "cidr" : "172.16.0.0/16" }, "authentication" : { "mode" : "x509", "authenticatingProxy" : { } }, "billingMode" : 0 }, "status" : { "phase" : "Available", "jobID" : "e8ebf96c-956d-11e8-a949-0255ac10575d", "endpoints" : [ { "url" : "https://192.168.0.16:5443", "type" : "Internal" } ] } }
SDK Sample Code
The SDK sample code is as follows.
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 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 DeleteClusterSolution { 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(); DeleteClusterRequest request = new DeleteClusterRequest(); request.withClusterId("{cluster_id}"); try { DeleteClusterResponse response = client.deleteCluster(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()); } } } |
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 |
# 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 = DeleteClusterRequest() request.cluster_id = "{cluster_id}" response = client.delete_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) |
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 |
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.DeleteClusterRequest{} request.ClusterId = "{cluster_id}" response, err := client.DeleteCluster(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 job for deleting a 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