我正在为 K8s REST API 使用 kubernetes-client java 库。我想探索这里描述的资源监控功能 https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
我在创建这样的部署时为 Pod 设置了资源
// ******************* RESOURCES*********************
Quantity memLimit = new Quantity();
memLimit.setAmount("400");
Map<String, Quantity> memMap = new HashMap<String,Quantity>();
memMap.put("memory", memLimit);
ResourceRequirements resourceRequirements = new ResourceRequirementsBuilder()
.withRequests(memMap)
.build();
// ******************* DEPLOYMENT *********************
Deployment deployment = new DeploymentBuilder()
.withNewMetadata()
.withName("first-deployment")
.endMetadata()
.withNewSpec()
.withReplicas(3)
.withNewTemplate()
.withNewMetadata()
.addToLabels(namespaceID, "hello-world-example")
.endMetadata()
.withNewSpec()
.addNewContainer()
.withName("nginx-one")
.withImage("nginx")
.addNewPort()
.withContainerPort(80)
.endPort()
.withResources(resourceRequirements)
.endContainer()
.endSpec()
.endTemplate()
.endSpec()
.build();
deployment = client.extensions().deployments().inNamespace(namespace).create(deployment);
我现在怎么知道在分配给 pod 的内存中使用了多少内存?文档说它是 pod status 的一部分,但 pod status 的形式是
(conditions=
[PodCondition
(lastProbeTime=null, lastTransitionTime=2018-01-09T15:53:28Z,
message=null, reason=null,
status=True, type=PodScheduled,
additionalProperties={})],
containerStatuses=[], hostIP=null,
initContainerStatuses=[],
message=null, phase=Pending, podIP=null,
qosClass=Burstable, reason=null,
startTime=null, additionalProperties={})
和容器状态
(containerID=null, image=nginx,
imageID=, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}),
name=nginx-one, ready=false, restartCount=0, state=ContainerState(running=null, terminated=null, waiting=
ContainerStateWaiting(message=null, reason=ContainerCreating, additionalProperties={}), additionalProperties={}),
additionalProperties={})
是否有监控 Pod 资源的示例?