容器往根文件系统写了很多东西会怎样?ephemeral-storage 的 limit 超了是 OOM 吗?emptyDir 和可写层是分开算还是合起来算?tmpfs 算不算?这篇各写 120 MiB 到三个地方,看哪个会被驱逐、多久被驱逐。
节点 worker:capacity.ephemeral-storage=485473984512;allocatable.ephemeral-storage=485473984512(= capacity,没有预留)
对照 df:节点上 /var 所在文件系统总大小 474095688 KiB(和 capacity 同一个来源:kubelet 的 imagefs/nodefs)
requests.ephemeral-storage: 100Ti 的 Pod:phase=Pending;[('PodScheduled', 'Unschedulable', '0/3 nodes are available: 1 node(s) had untolerated taint(s), 2 Insufficient ephemeral-storage. preemption: 0/3 nodes are available: 3 Preemp')]节点 worker 的 capacity.ephemeral-storage 是 485473984512 字节,allocatable 与它相同(没有预留),正好是节点上 /var 所在文件系统 df 显示的总大小(474095688 KiB)。requests.ephemeral-storage: 100Ti 的 Pod 一直 Pending,PodScheduled=False,0/3 nodes are available: … 2 Insufficient ephemeral-storage(控制面节点因污点被排除)。
写 120 MiB 到容器根文件系统(limit 50Mi):23 秒后 phase=Failed,reason=Evicted;message='Pod ephemeral local storage usage exceeds the total limit of containers 50Mi. ' 事件:['3s Warning Evicted pod/layer Pod ephemeral local storage usage exceeds the total limit of containers 50Mi.'] 被驱逐的 Pod 对象还在(Failed),容器已被杀;kubectl get 的 STATUS=Error
limits.ephemeral-storage: 50Mi 的容器往自己的根文件系统写 120 MiB:23 秒后 Pod 被驱逐,phase=Failed、reason=Evicted、message=Pod ephemeral local storage usage exceeds the total limit of containers 50Mi.,事件同样是 Evicted。被驱逐的 Pod 对象还在(Failed),容器已被杀。它不是 OOM,没有 OOMKilled,是 kubelet 周期性检查后主动驱逐的,所以有十几秒到几十秒的延迟。
写 120 MiB 到 emptyDir(Pod 总 limit 50Mi):33 秒后 phase=Failed,reason=Evicted;message='Pod ephemeral local storage usage exceeds the total limit of containers 50Mi. '
同样 limit 50Mi,往磁盘型 emptyDir 写 120 MiB:33 秒后同样 Failed / Evicted,message 也是 Pod ephemeral local storage usage exceeds the total limit of containers 50Mi.——kubelet 把容器可写层和磁盘型 emptyDir 合在一起,与 Pod 所有容器 limits 之和比较。
写 120 MiB 到 medium: Memory 的 emptyDir(ephemeral-storage limit 50Mi):100 秒后 phase=Running(没有被驱逐;这部分算内存,不算 ephemeral-storage) 对照 df:容器里 /data 的文件系统 tmpfs
medium: Memory 的 emptyDir 是 tmpfs:写 120 MiB 也不触发 ephemeral-storage 驱逐,100 秒后 Pod 仍是 Running——这部分算内存(计入容器内存),不算 ephemeral-storage(内存型 emptyDir 写超内存 limit 的后果见 k54)。