kubernetes: kubelet is creating a 0 byte file for each pod restart and is causing nodes to run out of inodes on filesystem

What happened:

For each restart of the pod, kubelet seems to write a 0 byte file into the /var/lib/kubelet/pods/<pod-id>/containers/<container-name>/:

# ls -lth | head
total 0
-rw-rw-rw-. 1 root root 0 Aug 26 00:54 6e8475d0
-rw-rw-rw-. 1 root root 0 Aug 26 00:46 8e462187
-rw-rw-rw-. 1 root root 0 Aug 26 00:40 bd4f31c5
-rw-rw-rw-. 1 root root 0 Aug 26 00:34 14ada185
-rw-rw-rw-. 1 root root 0 Aug 26 00:29 a287b35c
-rw-rw-rw-. 1 root root 0 Aug 26 00:23 6db0d4b3
-rw-rw-rw-. 1 root root 0 Aug 26 00:13 bf024d43
-rw-rw-rw-. 1 root root 0 Aug 26 00:03 f8043a73
-rw-rw-rw-. 1 root root 0 Aug 25 23:53 8c18a801

On k8s clusters where many pods are stuck in CrashLoopBackOff state kubelet will create millions of these 0 byte files, which can lead to nodes running out of inodes on a filesystem where /var/lib/kubelet is located. For example, in our clusters /var/lib/kubelet is on a small / filesystem with 512K inodes allocated and we found instances where the above described kubelet behavior exhausted inodes:

Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/sdb1        512K  502K   11K   98% /

What you expected to happen:

kubelet should keep the latest file (if it is needed) and delete files for any previous pod restarts.

How to reproduce it (as minimally and precisely as possible):

Start a broken pod that you know will go into CrashLoopBackOff. Login into a node where the pod gets scheduled and look at the files in the /var/lib/kubelet/pods/<pod-id>/containers/<container-name>/ directory.

Anything else we need to know?:

No.

Environment:

  • Kubernetes version (use kubectl version): tested with 1.15.4 and 1.19.9 (those are the versions we had running)
  • OS (e.g: cat /etc/os-release): Ubuntu 20.04
  • Kernel (e.g. uname -a): 5.4.0-62-generic

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 37 (16 by maintainers)

Most upvoted comments

I think #121181 is active? cc @Chaunceyctx

Yes, this PR attempts to fix this issue. However, there are still some problems with the PR that need to be addressed. I will work on improving it as soon as possible.