How much RAM can my Kubernetes pod grow to?

*爱你&永不变心* 提交于 2019-12-23 13:38:06

问题


I'd like to know the current limit on the RAM. (No limit/request was explicitly configured.)

How do I see the current configuration of an existing pod?

[Edit] That configuration would include not only how much memory is now in use, but also the max-limit, the point at which it would be shut down.

(If I blow up the heap with huge strings, I see a limit of approx 4 GB, and the Google Cloud Console shows a crash at 5.4 GB (which of course includes more than the Python interpreter), but I don't know where this comes from. The Nodes have up to 10 GB.)

I tried kubectl get pod id-for-the-pod -o yaml, but it shows nothing about memory.

I am using Google Container Engine.


回答1:


Use kubectl top command

kubectl top pod id-for-the-pod

kubectl top --help

Display Resource (CPU/Memory/Storage) usage.

The top command allows you to see the resource consumption for nodes or pods.

This command requires Heapster to be correctly configured and working on the server.

Available Commands: node Display Resource (CPU/Memory/Storage) usage of nodes pod Display Resource (CPU/Memory/Storage) usage of pods

Usage: kubectl top [flags] [options]




回答2:


The edit in the question asks how to see the max memory limit for an existing pod. This shold do:

kubectl -n <namespace> exec <pod-name> cat /sys/fs/cgroup/memory/memory.limit_in_bytes

Reference: https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt

With QoS class of BestEffort (seen in the output from kubectl -n <namespace> get pod <pod-name> -o yaml or kubectl -n <namespace> describe pod <pod-name>), there may be no limits (other than the available memory on the node where the pod is running) so the value returned can be a large number (e.g. 9223372036854771712 - see here for an explanation).




回答3:


You can use

kubectl top pod POD_NAME

It will show you memory and CPU usage.

[Edit: See comment for more]




回答4:


As already answered by the community, you can run "kubectl top pod POD_NAME" to get how much memory your pod is using. The max limit actually depends on the available memory of nodes (You may get an idea of CPU Requests and CPU Limits of nodes by running "kubectl describe nodes"). Furthermore, the max limit of the pod also depends on its memory requests and limits as defined in the pod's configuration ("requests" and "limits" specs under "resources"). You can also read this relevant link.




回答5:


Deploy Metrics Server in Kubernetes Cluster (Heapster is deprecated) and then use

kubectl top POD_NAME

to get pod CPU and memory usages.




回答6:


Answer from comment from @Artem Timchenko: kubectl -n NAMESPACE describe pod POD_NAME | grep -A 2 "Limits"



来源:https://stackoverflow.com/questions/53812196/how-much-ram-can-my-kubernetes-pod-grow-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!