删除网格 - DeleteMesh
功能介绍
该API用于删除一个指定的网格
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,需具备如下身份策略权限。
URI
DELETE /v1/{project_id}/meshes/{mesh_id}
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID。 |
|
mesh_id |
是 |
String |
网格ID。 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
调用接口的认证方式分为Token和AK/SK两种,如果您使用的Token方式,此参数为必填,请填写Token的值。 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
apiVersion |
String |
API版本,固定值“v1”,该值不可修改 |
|
kind |
String |
API类型,固定值“Mesh”或“mesh”,该值不可修改 |
|
metadata |
MeshMetadata object |
网格的基本信息,为集合类的元素类型,包含一组由不同名称定义的属性 |
|
spec |
MeshSpec object |
集合类的元素类型,您对需要管理的网格对象进行详细描述的主体部分都在spec中给出。ASM通过spec的描述来创建或更新对象 |
|
status |
MeshStatus object |
集合类的元素类型,用于记录对象在系统中的当前状态信息。 该对象为系统自动生成,不需要用户填写 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
name |
String |
网格名称。 命名规则:以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围4-64位,且不能以中划线(-)结尾 |
|
uid |
String |
网格ID,资源唯一标识,创建成功后自动生成,填写无效 |
|
creationTimestamp |
String |
网格创建时间 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
type |
String |
网格类型。 取值范围: |
|
version |
String |
网格版本。 |
|
extendParams |
MeshExtendParams object |
服务网格扩展信息。 |
|
ipv6Enable |
Boolean |
网格是否支持IPV6 |
|
tags |
Array of MeshTags objects |
网格资源标签。如果需要配置资源标签,请确认当前region的TMS服务已上线。 |
|
config |
MeshConfig object |
网格配置。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
clusterID |
String |
集群ID,资源唯一标识,通过该ID查询需要添加的集群 |
|
injection |
InjectionConfig object |
sidecar注入配置 |
|
installation |
InstallationConfig object |
网格组件安装配置 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
key |
String |
Key值 |
|
operator |
String |
操作符,仅支持取值"In" |
|
values |
Array of strings |
Value值 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
key |
String |
Key值。 不能为空,最多支持128个字符 可用UTF-8格式表示的汉字、字母、数字和空格 支持部分特殊字符:_.:/=+-@ 不能以"sys"开头 |
|
value |
String |
Value值。 可以为空但不能缺省,最多支持255个字符 可用UTF-8格式表示的汉字、字母、数字和空格 支持部分特殊字符:_.:/=+-@ |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
proxyConfig |
ProxyConfig object |
网格数据面配置 |
|
telemetryConfig |
TelemetryConfig object |
网格的可观测性配置 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
includeIPRanges |
String |
拦截对外访问的地址范围,以半角英文逗号(,)分隔的IP网段 |
|
excludeIPRanges |
String |
排除拦截对外访问的地址范围,以半角英文逗号(,)分隔的IP网段 |
|
excludeOutboundPorts |
String |
排除拦截对外访问端口,以半角英文逗号(,)分隔的出站端口列表 |
|
excludeInboundPorts |
String |
排除拦截访问服务的端口,以半角英文逗号(,)分隔的入站端口列表 |
|
includeOutboundPorts |
String |
拦截对外访问端口,以半角英文逗号(,)分隔的出站端口列表 |
|
includeInboundPorts |
String |
拦截访问服务的端口,以半角英文逗号(,)分隔的入站端口列表 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
metrics |
Metric object |
应用指标配置,用于上报ASM网格指标数据。如果要启用该配置,集群需安装云原生监控插件。 |
|
accessLogging |
AccessLogging object |
AccessLog配置,用于上报ASM网格内Istio代理的访问日志。如果要启用该配置,集群需安装云原生日志采集插件。 |
|
tracing |
Tracing object |
Tracing配置,用于上报ASM网格内的调用链数据。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
randomSamplingPercentage |
Float |
tracing采样率 |
|
defaultProviders |
Array of strings |
tracing默认上报的provider名称,必须与extensionProviders中的name字段匹配,或使用ASM预设的provider "apm-otel"。 如果使用"apm-otel",需确认当前region已支持APM2.0且网格版本大于1.18。 |
|
extensionProviders |
Array of TracingExtensionProvider objects |
用户自配置provider,目前支持zipkin协议。 如果用户配置zipkin协议的provider,请保证网格版本大于等于1.15。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
name |
String |
provider实例name |
|
zipkin |
ZipkinTracingProvider object |
zipkin协议provider自有配置 |
状态码:400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
errorCode |
String |
错误码 |
|
errorMsg |
String |
错误描述 |
状态码:404
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
errorCode |
String |
错误码 |
|
errorMsg |
String |
错误描述 |
状态码:500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
errorCode |
String |
错误码 |
|
errorMsg |
String |
错误描述 |
请求示例
无
响应示例
状态码:200
表示删除指定网格任务下发成功,开始删除网格
{
"kind" : "Mesh",
"apiVersion" : "v1",
"metadata" : {
"name" : "mesh-test-api",
"uid" : "a1efdc3e-xxxx-xxxx-xxxx-94bef433347e",
"creationTimestamp" : "2025-04-10T07:48:37Z"
},
"spec" : {
"type" : "InCluster",
"version" : "1.18.7-r5",
"config" : {
"telemetryConfig" : {
"metrics" : {
"aom" : [ {
"instanceID" : "602a5b7e-xxxx-xxxx-xxxx-4268c35b0424"
} ]
},
"accessLogging" : {
"lts" : [ {
"logGroupID" : "b884eaeb-xxxx-xxxx-xxxx-f442de73c392",
"logStreamID" : "362e11e8-xxxx-xxxx-xxxx-0afdc68da7d2"
} ]
},
"tracing" : {
"randomSamplingPercentage" : 1,
"defaultProviders" : [ "zipkin" ],
"extensionProviders" : [ {
"name" : "zipkin",
"zipkin" : {
"service" : "zipkin.monitoring.svc.cluster.local",
"port" : 9411
}
} ]
}
},
"proxyConfig" : {
"includeIPRanges" : "10.247.0.0/16"
}
},
"extendParams" : {
"clusters" : [ {
"clusterID" : "cb0ef541-xxxx-xxxx-xxxx-0255ac1001b7"
} ]
}
},
"status" : {
"phase" : "Deleting",
"updateTimestamp" : "2025-04-10T08:10:45Z"
}
}
SDK代码示例
SDK代码示例如下。
Java
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.asm.v1.region.AsmRegion; import com.huaweicloud.sdk.asm.v1.*; import com.huaweicloud.sdk.asm.v1.model.*; public class DeleteMeshSolution { 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); AsmClient client = AsmClient.newBuilder() .withCredential(auth) .withRegion(AsmRegion.valueOf("<YOUR REGION>")) .build(); DeleteMeshRequest request = new DeleteMeshRequest(); request.withMeshId("{mesh_id}"); try { DeleteMeshResponse response = client.deleteMesh(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()); } } } |
Python
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 huaweicloudsdkasm.v1.region.asm_region import AsmRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkasm.v1 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 = AsmClient.new_builder() \ .with_credentials(credentials) \ .with_region(AsmRegion.value_of("<YOUR REGION>")) \ .build() try: request = DeleteMeshRequest() request.mesh_id = "{mesh_id}" response = client.delete_mesh(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
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" asm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/asm/v1/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 := asm.NewAsmClient( asm.AsmClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.DeleteMeshRequest{} request.MeshId = "{mesh_id}" response, err := client.DeleteMesh(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
表示删除指定网格任务下发成功,开始删除网格 |
|
400 |
用户提供的参数有问题,未通过校验 |
|
404 |
未找到指定的网格 |
|
500 |
查询过程中出现问题 |
错误码
请参见错误码。