I am using the kubernetes-client java library for the K8s REST API. I want to explore the resource monitoring feature desctibed here https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
I set the resource for the Pods while creating Deployments like this
// ******************* 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);
How do I now know, how much memory is being used out of the alocated memory for pods? The documentation says its part of the pod status , but pod status is of the form
(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={})
And the container status
(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={})
Is there an example for monitoring resources on Pods?