Inside a namespace, I have created a pod with its specs consisting of memory limit and memory requests parameters. Once up a and running, I would like to know how can I get the memory utilization of the pod in order to figure out if the memory utilization is within the specified limit or not. "kubectl top" command returns back with a services related error.
-
You should likely resolve your `kubectl top` issue, you can see the cpu and memory usage of your given pod like this: `kubectl top pod ${POD_NAME}`. – cookiedough Feb 25 '19 at 22:14
4 Answers
kubectl top pod <pod-name> -n <fed-name> --containers
FYI, this is on v1.16.2

- 2,106
- 1
- 7
- 12
kubectl top pod POD_NAME --containers
shows metrics for a given pod and its containers. If you want to see graphs of memory and cpu utilization then you can see them through the kubernetes dashboard. A better solution would be to install a metrics server alongwith prometheus and grafana in your cluster. Prometheus will scrape the metrics which can be used by grafana for displaying as graphs. This might be useful.

- 6,656
- 4
- 18
- 22

- 301
- 2
- 15
You need to install metrics server to get the metrics. Follow the below thread
Error from server (NotFound): podmetrics.metrics.k8s.io "mem-example/memory-demo" not found

- 15,499
- 7
- 34
- 59
Instead of building ad-hoc metric snapshots, a much better way is to install and work with 3rd party data collector programs which if managed well gives you a great solution for monitoring systems and a neat Grafana UI (or likewise) you can play with. One of them is Prometheus and which comes highly recommended.
using such PnP systems, you can not only create a robust monitoring pipeline but also the consumption and hence the reaction to the problem is well managed and executed compared to only relying on TOP

- 1,541
- 1
- 12
- 21