Manuel Castro
Manuel Castro

Reputation: 1723

Check pod resources consumption

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?

Upvotes: 5

Views: 3737

Answers (2)

weibeld
weibeld

Reputation: 15232

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.

Upvotes: 6

Blokje5
Blokje5

Reputation: 4993

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

kubectl top pod
kubectl top node

Upvotes: 8

Related Questions