查询pod详细信息
功能介绍
查询pod详细信息
调用方法
请参见如何调用API。
URI
GET /v5/{project_id}/kubernetes/{pod_name}/pod/detail
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,用于明确项目归属,配置后可通过该ID查询项目下资产。获取方式请参见获取项目ID。 约束限制: 不涉及 取值范围: 字符长度1-256位 默认取值: 不涉及 |
pod_name |
是 |
String |
pod名称 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
enterprise_project_id |
否 |
String |
参数解释: 企业项目ID,用于过滤不同企业项目下的资产。获取方式请参见获取企业项目ID。 如需查询所有企业项目下的资产请传参“all_granted_eps”。 约束限制: 开通企业项目功能后才需要配置企业项目ID参数。 取值范围: 字符长度1-256位 默认取值: 0,表示默认企业项目(default)。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token,包含了用户的身份、权限等信息,在调用API接口时,可通过Token进行身份认证。获取方式请参见获取用户Token。 约束限制: 不涉及 取值范围: 字符长度1-32768位 默认取值: 不涉及 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
pod_name |
String |
pod名称 |
namespace_name |
String |
命名空间名称 |
cluster_name |
String |
所属集群 |
node_name |
String |
所属节点名称 |
label |
String |
标签 |
cpu |
String |
CPU使用量 |
memory |
String |
内存使用量 |
cpu_limit |
String |
cpu限制 |
memory_limit |
String |
内存限制 |
node_ip |
String |
所属节点IP |
pod_ip |
String |
Pod IP |
status |
String |
Pod状态,包含以下几种 -Pending:pod已被Kubernetes系统接受,但尚未创建一个或多个容器镜像 -Running:pod已经绑定到一个节点,并且所有的容器都已经创建完毕 -Succeeded:pod中的所有容器都已成功终止,不会重新启动 -Failed:pod中的所有容器都已终止,并且至少有一个容器因故障而终止 -Unknown:由于某种原因无法获取pod的状态,通常是由于与pod的主机通信时出错 |
create_time |
Long |
创建时间 |
containers |
Array of ContainerBaseInfo objects |
pod容器列表 |
参数 |
参数类型 |
描述 |
---|---|---|
id |
String |
参数解释: ID 取值范围: 字符长度0-255位 |
region_id |
String |
参数解释: 区域 取值范围: 字符长度0-255位 |
container_id |
String |
参数解释: 容器ID 取值范围: 字符长度0-255位 |
container_name |
String |
参数解释: 容器名称 取值范围: 字符长度0-255位 |
image_name |
String |
参数解释: 镜像名称 取值范围: 字符长度0-255位 |
status |
String |
参数解释: 容器状态 取值范围:
|
create_time |
Long |
参数解释: 创建时间 取值范围: 取值0-4071095999000 |
cpu_limit |
String |
参数解释: cpu限制 取值范围: 字符长度0-64位 |
memory_limit |
String |
参数解释: 内存限制 取值范围: 字符长度0-64位 |
restart_count |
Integer |
参数解释: 重启次数 取值范围: 取值0-20 |
pod_name |
String |
参数解释: 所属pod名称 取值范围: 字符长度0-64位 |
cluster_name |
String |
参数解释: 所属集群 取值范围: 字符长度0-64位 |
cluster_id |
String |
参数解释: 集群id 取值范围: 字符长度0-64位 |
cluster_type |
String |
参数解释: 集群类型 取值范围:
|
risky |
Boolean |
参数解释: 是否有风险 取值范围: true和false,true代表有风险,false代表无风险 |
low_risk |
Integer |
参数解释: 低危风险数量 取值范围: 取值0-2147483647 |
medium_risk |
Integer |
参数解释: 中危风险数量 取值范围: 取值0-2147483647 |
high_risk |
Integer |
参数解释: 高危风险数量 取值范围: 取值0-2147483647 |
fatal_risk |
Integer |
参数解释: 致命风险数量 取值范围: 取值0-2147483647 |
请求示例
查询pod详细信息
GET https://{endpoint}/v5/{project_id}/kubernetes/node-local-dns-admission-controller-678d87b4cc-78qqt/pod/detail?enterprise_project_id=all_granted_eps
响应示例
状态码:200
请求已成功
{ "pod_name" : "node-local-dns-admission-controller-678d87b4cc-78qqt", "namespace_name" : "kube-system", "node_name" : "192.168.1.18", "label" : "{\"release\":\"cceaddon-node-local-dns\",\"pod-template-hash\":\"678d87b4cc\",\"k8s-app\":\"node-local-dns-admission-controller\"}", "node_ip" : "192.168.1.18", "pod_ip" : "192.168.1.166", "status" : "Running", "create_time" : 1720916013000, "containers" : [ { "id" : "66a9f98c-xxxx-xxxx-xxxx-37f99fbed435", "container_id" : "b9e0fc15f74ccff251736c3e091f57b239b4d1ee25da615e1000e59aef54c98f", "container_name" : "webhook", "image_name" : "hwofficial/local-dns-admission-controller:1.6.8", "status" : "Running", "create_time" : 1720916341000, "restart_count" : 0, "pod_name" : "node-local-dns-admission-controller-678d87b4cc-78qqt", "cluster_name" : "glz-2451", "cluster_id" : "a03efb0c-xxxx-xxxx-xxxx-0255ac100b0b", "region_id" : "cn-north-7" } ], "cluster_name" : "glz-2451" }
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 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.hss.v5.region.HssRegion; import com.huaweicloud.sdk.hss.v5.*; import com.huaweicloud.sdk.hss.v5.model.*; public class ShowK8sPodDetailSolution { 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); HssClient client = HssClient.newBuilder() .withCredential(auth) .withRegion(HssRegion.valueOf("<YOUR REGION>")) .build(); ShowK8sPodDetailRequest request = new ShowK8sPodDetailRequest(); request.withPodName("{pod_name}"); try { ShowK8sPodDetailResponse response = client.showK8sPodDetail(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 huaweicloudsdkhss.v5.region.hss_region import HssRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkhss.v5 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 = HssClient.new_builder() \ .with_credentials(credentials) \ .with_region(HssRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowK8sPodDetailRequest() request.pod_name = "{pod_name}" response = client.show_k8s_pod_detail(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" hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/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 := hss.NewHssClient( hss.HssClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowK8sPodDetailRequest{} request.PodName = "{pod_name}" response, err := client.ShowK8sPodDetail(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求已成功 |
错误码
请参见错误码。