Check pod resources consumption

9/13/2019

I've got some deployment on a basic k8s cluster withouth defining requests and limits. Is there any way to check how much the pod is asking for memory and cpu?

-- Manuel Castro
azure-kubernetes
kubernetes
kubernetes-pod

2 Answers

9/13/2019

After installing the Metrics Server, you can query the Resource Metrics API directly for the resource usages of pods and nodes:

  • All nodes in the cluster:
    • kubectl get --raw=/apis/metrics.k8s.io/v1beta1/nodes
  • A specific node:
    • kubectl get --raw=/apis/metrics.k8s.io/v1beta1/nodes/{node}
  • All pods in the cluster:
    • kubectl get --raw=/apis/metrics.k8s.io/v1beta1/pods
  • All pods in a specific namespace:
    • kubectl get --raw=/apis/metrics.k8s.io/v1beta1/namespaces/{namespace}/pods
  • A specific pod:
    • kubectl get --raw=/apis/metrics.k8s.io/v1beta1/namespaces/{namespace}/pods/{pod}

The API returns you the absolute CPU and memory usages of the pods and nodes.

From this, you should be able to figure out how much resources each pod consumes and how much free resources are left on each node.

-- weibeld
Source: StackOverflow

9/13/2019

Depending on whether the metrics-server is installed in your cluster, you can use:

kubectl top pod
kubectl top node
-- Blokje5
Source: StackOverflow