I am trying to see how much memory and CPU is utilized by a kubernetes pod. I ran the following command for this:
kubectl top pod podname --namespace=default
I am getting the following error:
W0205 15:14:47.248366 2767 top_pod.go:190] Metrics not available for pod default/podname, age: 190h57m1.248339485s
error: Metrics not available for pod default/podname, age: 190h57m1.248339485s
- What do I do about this error? Is there any other way to get CPU and memory usage of the pod?
I saw the sample output of this command which shows CPU as 250m. How is this to be interpreted?
Do we get the same output if we enter the pod and run the linux
top
command?
As heapster is deprecated and will not be releasing any future releases, you should go with installing metrics-server
You can install metrics-server in following way:
git clone https://github.com/kubernetes-incubator/metrics-server.git
Edit the
deploy/1.8+/metrics-server-deployment.yaml
file and add following section just aftercommand
section:kubectl apply -f deploy/1.8+
It will install all the requirements you need for metrics server.
For more info, please have a look at my following answer:
As described in the docs, you should install metrics-server
250m means 250 milliCPU, The CPU resource is measured in CPU units, in Kubernetes, is equivalent to:
No,
kubectl top pod podname
shows metrics for a given pod, Linuxtop
andfree
runs inside a Container and report metrics based on Linux system reporting based on the information stored in the virtual filesystem/proc/
, they are not aware of the cgroup where it runs.There are more details on these links:
kubectl top pod <pod-name> -n <fed-name> --containers
FYI, this is on v1.16.2
you need to deploy heapster or metric server to see the cpu and memory usage of the pods