繁体   English   中英

使用 emptyDir 介质的缺点 = memory

[英]Disadvantage of using emptyDir medium = memory

我觉得我误解了 Kubernetes 中基于 RAM 的emptyDir卷。

  1. 假设我的 Kubernetes 节点总共有 100GB。 如果我有 4 个不同的 emptyDirs,它们的emptyDir.medium设置为“内存”,默认情况下它们都会有 50GB 的 memory 吗? 在这种情况下,当我的 4 个 emptyDirs 中使用的 memory 总量超过 100GB 时会发生什么?

  2. 我知道一般 RAM 很快,但有哪些缺点示例? 官方文档中,我看到了以下内容,但我不太明白该声明。 我的理解是,如果 Pod 崩溃,使用磁盘的 emptyDirs 上的文件仍然会被删除。 如果文件存储在磁盘中,是否会在节点重新启动时保留这些文件? 另外, count against container memory limit是什么意思?

While tmpfs is very fast, be aware that unlike disks, 
tmpfs is cleared on node reboot and any files you 
write count against your container's memory limit

...by default will they all have 50GBs of memory?

是的。 您可以执行到 pod 并使用df -h检查。 如果您的集群启用了SizeMemoryBackedVolumes功能,您可以指定大小。

...what happens when the total amount of memory used in my 4 emptyDirs exceeds 100GB?

你不会有这个机会,因为当所有 emptyDir(s) 使用的 memory 总量达到 50GB 时; 您的 pod 将被驱逐。 它不需要一个 emptyDir 来达到 50GB 来驱逐

...don't quite understand the statement.

这意味着您将无法取回存储在 emptyDir 上的数据。

count against container memory limit

这意味着您使用 emptyDir 消耗的 memory 的数量被添加到您的容器使用的 memory 的数量中,并检查 resources.limits.memory。

相同的 文档页面

当 Pod 因任何原因从节点中移除时,emptyDir 中的数据将被永久删除。

注意:容器崩溃不会从节点中删除 Pod。 emptyDir 卷中的数据在容器崩溃时是安全的。

所以 pod crash 不会导致emptyDir卷被清除。

关于 memory 支持卷的一般用法:始终指定 pod memory 限制,否则您可能会遇到各种反直觉的 pod 驱逐等意外。

此外,如果您打算主动写入 memory 支持的卷(这就是 memory 的用途),您需要仔细控制写入的数据量,否则您可能会遇到奇怪的应用程序崩溃。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM