临时存储垃圾收集

Ephemeral Storage Garbage Collection

我在容器上指定了临时存储限制和请求,并且我使用的是最新的 amazon-eks-node-1.12-v20190701 映像。

我的问题是,当我指定 ephemeral-storage: 1Mi 时,我的 pod 因使用过多而被驱逐。我可以很容易地添加更多,但我想知道它到底是如何工作的,而 kubernetes 文档不是很有帮助。

根据我的阅读,有一个垃圾收集器 that will clean up unused images and unused containers. Kubelet will perform garbage collection for containers every minute and garbage collection for images every five minutes.

这也适用于临时存储吗?

如何检查临时存储中的内容(通过容器或节点?)以及如何减少它?

当 ephemeral-storage 达到 85% 和垃圾收集 运行 时,它会被清理是真的吗?

抱歉问了很多问题,只是想了解一下,很难找到一个简单的答案

据我所知(如果有误,请纠正我)临时存储没有垃圾收集。

我们可以在 Kubernetes 文档中读到关于 Garbage Collection

Some Kubernetes objects are owners of other objects. For example, a ReplicaSet is the owner of a set of Pods. The owned objects are called dependents of the owner object. Every dependent object has a metadata.ownerReferences field that points to the owning object.

Sometimes, Kubernetes sets the value of ownerReference automatically. For example, when you create a ReplicaSet, Kubernetes automatically sets the ownerReference field of each Pod in the ReplicaSet. In 1.8, Kubernetes automatically sets the value of ownerReference for objects created or adopted by ReplicationController, ReplicaSet, StatefulSet, DaemonSet, Deployment, Job and CronJob.

You can also specify relationships between owners and dependents by manually setting the ownerReference field.

所以我们可以利用垃圾回收来删除依赖对象。

When you delete an object, you can specify whether the object’s dependents are also deleted automatically. Deleting dependents automatically is called cascading deletion. There are two modes of cascading deletion: background and foreground.

If you delete an object without deleting its dependents automatically, the dependents are said to be orphaned.

在 Kubernetes v1.16 中引入了新资源 Local ephemeral storage >

In each Kubernetes node, kubelet’s root directory (/var/lib/kubelet by default) and log directory (/var/log) are stored on the root partition of the node. This partition is also shared and consumed by Pods via emptyDir volumes, container logs, image layers and container writable layers.

并回答你的问题

How do I check what’s inside the ephemeral storage (via container or a node?) and how can I reduce it?

可能可以执行到安装了存储的 docker 容器并查看那里有什么,但除此之外我看不到访问内容的方法。 至于减少存储(我没有测试过)它可能会删除临时存储的内容,因为它不可扩展。