简体   繁体   English

使用 emptyDir 介质的缺点 = memory

[英]Disadvantage of using emptyDir medium = memory

I feel like I am misunderstanding RAM based emptyDir volumes in Kubernetes.我觉得我误解了 Kubernetes 中基于 RAM 的emptyDir卷。

  1. Let's suppose my Kubernetes node has a total of 100GB.假设我的 Kubernetes 节点总共有 100GB。 If I have 4 different emptyDirs that have emptyDir.medium set to "Memory", by default will they all have 50GBs of memory?如果我有 4 个不同的 emptyDirs,它们的emptyDir.medium设置为“内存”,默认情况下它们都会有 50GB 的 memory 吗? In that case what happens when the total amount of memory used in my 4 emptyDirs exceeds 100GB?在这种情况下,当我的 4 个 emptyDirs 中使用的 memory 总量超过 100GB 时会发生什么?

  2. I know in general RAM is fast, but what are some examples for the downsides?我知道一般 RAM 很快,但有哪些缺点示例? From the official documentation , I see the below but I don't quite understand the statement.官方文档中,我看到了以下内容,但我不太明白该声明。 My understanding is that if a Pod crashes, files on emptyDirs using disk will still be deleted.我的理解是,如果 Pod 崩溃,使用磁盘的 emptyDirs 上的文件仍然会被删除。 Will the files be kept upon node reboot if they are stored in disk?如果文件存储在磁盘中,是否会在节点重新启动时保留这些文件? Also what do they mean by count against container memory limit ?另外, 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?

Yes.是的。 You can exec into the pod and check with df -h .您可以执行到 pod 并使用df -h检查。 If your cluster has SizeMemoryBackedVolumes feature enabled, you can specify the size.如果您的集群启用了SizeMemoryBackedVolumes功能,您可以指定大小。

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

You won't get that chance because the moment the total amount of memory used by all emptyDir(s) reach 50GB;你不会有这个机会,因为当所有 emptyDir(s) 使用的 memory 总量达到 50GB 时; your pod will be evicted.您的 pod 将被驱逐。 It doesn't need a single emptyDir to reach 50GB to evict .它不需要一个 emptyDir 来达到 50GB 来驱逐

...don't quite understand the statement.

It means you will not get back the data storing on emptyDir.这意味着您将无法取回存储在 emptyDir 上的数据。

count against container memory limit

It means the amount of memory that you consumed using emptyDir is added to the amount of the memory that your container used and check against the resources.limits.memory.这意味着您使用 emptyDir 消耗的 memory 的数量被添加到您的容器使用的 memory 的数量中,并检查 resources.limits.memory。

Same documentation page :相同的 文档页面

When a Pod is removed from a node for any reason, the data in the emptyDir is deleted permanently.当 Pod 因任何原因从节点中移除时,emptyDir 中的数据将被永久删除。

Note: A container crashing does not remove a Pod from a node.注意:容器崩溃不会从节点中删除 Pod。 The data in an emptyDir volume is safe across container crashes. emptyDir 卷中的数据在容器崩溃时是安全的。

So pod crash does not cause emptyDir volume to be cleared.所以 pod crash 不会导致emptyDir卷被清除。

Regarding general usage of memory backed volumes: always specify pod memory limit otherwise you may face surprises like various counter-intuitive pod evictions.关于 memory 支持卷的一般用法:始终指定 pod memory 限制,否则您可能会遇到各种反直觉的 pod 驱逐等意外。

Also if you're planning to actively write to memory backed volume (that's what memory is for) you need to carefully control how much data is written otherwise you may face strange application crashes.此外,如果您打算主动写入 memory 支持的卷(这就是 memory 的用途),您需要仔细控制写入的数据量,否则您可能会遇到奇怪的应用程序崩溃。

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

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