删除PVC(待废弃)
功能介绍
该API用于删除指定Namespace下的PVC(PersistentVolumeClaim)对象,并可以选择保留后端的云存储。该API待废弃,请使用Kubernetes PVC相关接口。
存储管理的URL格式为:https://{clusterid}.Endpoint/uri。其中{clusterid}为集群ID,uri为资源路径,也即API访问的路径。如果使用https://Endpoint/uri,则必须指定请求header中的X-Cluster-ID参数。
调用方法
请参见如何调用API。
URI
DELETE /api/v1/namespaces/{namespace}/cloudpersistentvolumeclaims/{name}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
需要删除的PersistentVolumClaim的名称。 |
namespace |
是 |
String |
指定PersistentVolumeClaim所在的命名空间。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
deleteVolume |
否 |
String |
删除PersistentVolumeClaim后是否保留后端关联的云存储。false表示不删除,true表示删除,默认为false。 |
storageType |
否 |
String |
云存储的类型,和deleteVolume搭配使用。即deleteVolume和storageType必须同时配置。
|
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
Content-Type |
是 |
String |
消息体的类型(格式) |
X-Auth-Token |
是 |
String |
调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值,获取方式请参见获取token。 |
X-Cluster-ID |
否 |
String |
集群ID,使用https://Endpoint/uri这种URL格式时必须指定此参数。获取方式请参见如何获取接口URI中参数。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
API版本,固定值v1 |
kind |
String |
API类型,固定值PersistentVolumeClaim |
metadata |
metadata是集群对象的元数据定义,是集合类的元素类型,包含一组由不同名称定义的属性。 |
|
spec |
PersistentVolumeClaimSpec object |
spec是集合类的元素类型,用户对需要管理的集群对象进行详细描述的主体部分都在spec中给出。系统通过spec的描述来创建或更新对象。 |
status |
PersistentVolumeClaimStatus object |
status是当前PersistentVolumeClaim的状态信息,创建时不需要添加status参数。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
PersistentVolumeClaim名称,可以包含小写字母、数字、连字符和点,开头和结尾必须是字母或数字,最长253个字符,同一namespace下name不能重复。 |
labels |
String |
PersistentVolumeClaim标签,key/value对格式。
|
参数 |
参数类型 |
描述 |
---|---|---|
volumeID |
String |
资源需为已经存在的存储资源
|
storageType |
String |
云存储的类型,和volumeID搭配使用。即volumeID和storageType必须同时被配置。
|
accessModes |
Array of strings |
指定volume应该具有的访问模式,列表中仅第一个配置参数有效。
|
storageClassName |
String |
PVC的StorageClass名称 |
volumeName |
String |
PVC绑定的PV名称 |
resources |
ResourceRequirements object |
资源需求和限制 |
volumeMode |
String |
PVC指定的PV类型 |
请求示例
无
响应示例
无
SDK代码示例
SDK代码示例如下。
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 |
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 DeleteCloudPersistentVolumeClaimsSolution { 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"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); CceClient client = CceClient.newBuilder() .withCredential(auth) .withRegion(CceRegion.valueOf("<YOUR REGION>")) .build(); DeleteCloudPersistentVolumeClaimsRequest request = new DeleteCloudPersistentVolumeClaimsRequest(); request.withName("{name}"); request.withNamespace("{namespace}"); try { DeleteCloudPersistentVolumeClaimsResponse response = client.deleteCloudPersistentVolumeClaims(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"] credentials = BasicCredentials(ak, sk) client = CceClient.new_builder() \ .with_credentials(credentials) \ .with_region(CceRegion.value_of("<YOUR REGION>")) \ .build() try: request = DeleteCloudPersistentVolumeClaimsRequest() request.name = "{name}" request.namespace = "{namespace}" response = client.delete_cloud_persistent_volume_claims(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 |
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") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := cce.NewCceClient( cce.CceClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.DeleteCloudPersistentVolumeClaimsRequest{} request.Name = "{name}" request.Namespace = "{namespace}" response, err := client.DeleteCloudPersistentVolumeClaims(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
删除指定PersistentVolumeClaim作业下发成功。 |
错误码
请参见错误码。