Kubernetes pods: how to get pod stats?

11/12/2020

I have some pods running a server:

NAME                            READY   STATUS    RESTARTS   AGE
hello-python-6c7b478cf5-hxfvb   1/1     Running   0          7m16s
hello-python-6c7b478cf5-rczp9   1/1     Running   0          7m16s
hello-python-6c7b478cf5-snww5   1/1     Running   0          7m16s
hello-python-6c7b478cf5-wr8gf   1/1     Running   0          7m16s

I would like to get some "stats" for a given pod. For example, what percentage of requests has a given pod been handling.

How do I do this with kubectl?

-- nz_21
kubectl
kubernetes
python

1 Answer

11/12/2020

What you can do is running kubectl describe pod <pod_name> -n <namespace_name>, but this won't you give the percentage of requests that have been handled through this pod (that should be divided quite evenly among the pods to be honest).

For more detailed stats, you can use something like metrics-server or prometheus. See some more information about monitoring Kubernetes resources in the documentation.

-- mlang
Source: StackOverflow