功能介绍
获取指定namespace下指定pod的metrics信息
调用方法
请参见如何调用API。
URI
GET /apis/metrics.k8s.io/v1beta1/namespaces/{namespace}/pods/{name}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
是 |
String |
name of the PodMetrics |
namespace |
是 |
String |
object name and auth scope, such as for teams and projects |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
pretty |
否 |
String |
If 'true', then the output is pretty printed. |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
Container name corresponding to the one from pod.spec.containers. |
usage |
Map<String,String> |
The memory usage is the memory working set. |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
name of the process that is responsible for initializing this object. |
参数 |
参数类型 |
描述 |
---|---|---|
field |
String |
The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional. Examples: "name" - the field "name" on the current resource "items[0].name" - the field "name" on the first array entry in "items" |
message |
String |
A human-readable description of the cause of the error. This field may be presented as-is to a reader. |
reason |
String |
A machine-readable description of the cause of the error. If this value is empty there is no information available. |
参数 |
参数类型 |
描述 |
---|---|---|
continue |
String |
continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message. |
resourceVersion |
String |
String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#concurrency-control-and-consistency |
selfLink |
String |
selfLink is a URL representing this object. Populated by the system. Read-only. |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. |
fields |
Object |
Fields identifies a set of fields. |
manager |
String |
Manager is an identifier of the workflow managing these fields. |
operation |
String |
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. |
time |
String |
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
API version of the referent. |
blockOwnerDeletion |
Boolean |
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. |
controller |
Boolean |
If true, this reference points to the managing controller. |
kind |
String |
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds |
name |
String |
Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names |
uid |
String |
UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids |
请求示例
无
响应示例
状态码: 200
OK
{
"apiVersion" : "metrics.k8s.io/v1beta1",
"containers" : [ {
"name" : "container-0",
"usage" : {
"cpu" : "353450n",
"cpu_accumulated" : "127810375798n",
"memory" : "1560Ki",
"memory_rss" : "284Ki",
"memory_usage" : "1824Ki"
}
} ],
"kind" : "PodMetrics",
"metadata" : {
"creationTimestamp" : "2023-03-28T11:28:23Z",
"name" : "cci-deployment-20233231-6c8d7f74f7-2t6k5",
"namespace" : "cci-namespace-13238101",
"selfLink" : "/apis/metrics.k8s.io/v1beta1/namespaces/cci-namespace-13238101/pods/cci-deployment-20233231-6c8d7f74f7-2t6k5"
},
"timestamp" : "2023-03-28T11:28:02Z",
"window" : "30s"
}
状态码
状态码 |
描述 |
---|---|
200 |
OK |
400 |
BadRequest |
401 |
Unauthorized |
403 |
Forbidden |
404 |
NotFound |
405 |
MethodNotAllowed |
406 |
NotAcceptable |
409 |
Conflict |
415 |
UnsupportedMediaType |
422 |
Invalid |
429 |
TooManyRequests |
500 |
InternalError |
503 |
ServiceUnavailable |
504 |
ServerTimeout |