我的 Kubernetes pod 可以增长到多少 RAM?

How much RAM can my Kubernetes pod grow to?

我想知道 RAM 的当前限制。 (未明确配置 limit/request。)

如何查看现有 pod 的当前配置?

[编辑] 该配置不仅包括现在正在使用的内存量,还包括最大限制,即关闭的点。

(如果我用巨大的字符串炸毁堆,我会看到大约 4 GB 的限制,并且 Google Cloud Console 显示 5.4 GB 时崩溃(当然包括超过 Python解释器),但我不知道这是从哪里来的。节点最多有10 GB。)

我试过 kubectl get pod id-for-the-pod -o yaml,但它没有显示内存。

我正在使用 Google 容器引擎。

使用 kubectl top 命令

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]

您可以使用

kubectl top pod POD_NAME

它将显示内存和 CPU 使用情况。

[编辑:更多信息见评论]

在 Kubernetes 集群中部署 Metrics Server(Heapster 已弃用),然后使用

kubectl top POD_NAME

获取 pod CPU 和内存使用情况。

正如社区已经回答的那样,您可以 运行 "kubectl top pod POD_NAME" 了解您的 pod 使用了多少内存。最大限制实际上取决于节点的可用内存(您可以通过 运行ning "kubectl describe nodes" 了解 CPU 请求和 CPU 节点限制。此外,pod 的最大限制还取决于其 memory requests and limits as defined in the pod's configuration ("requests" and "limits" specs under "resources"). You can also read this relevant .

问题中的编辑询问如何查看现有 pod 的最大内存限制。这样做:

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

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

使用 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 的 QoS class 进行解释)。

来自@Artem Timchenko 评论的回答:kubectl -n NAMESPACE describe pod POD_NAME | grep -A 2 "Limits"