<p>Today I found the host kubernetes(v1.21.3) folder <code>io.containerd.snapshotter.v1.overlayfs</code> takes too much spaces:</p>
<pre><code>[root@k8smasterone kubernetes.io~nfs]# pwd
/var/lib/kubelet/pods/8aafe99f-53c1-4bec-8cb8-abd09af1448f/volumes/kubernetes.io~nfs
[root@k8smasterone kubernetes.io~nfs]# duc ls -Fg /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/
 13.5G snapshots/   [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]
  2.2M metadata.db  [
</code></pre>
<p>It takes 13.5GB of disk spaces. is it possible to shrink this folder?</p>

Dolphin
<p>The directory <code>/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs</code> is where the various container and image layers are persisted by containerd. These layers are downloaded based on the containers running on the node. If we start running out of space, the kubelet has the ability to garbage collected unused images - which will reduce the size of this directory. The customer also has the ability to configure the size of the boot disk for the node-pools if needed.</p>
<p>It is expected that this would grow from the time a node is created. However when the node disk usage is above 85% then garbage collection will attempt to identify images that can be removed. It may not be able to remove images though if they are currently in use by an existing container running on the node or they have been recently pulled.</p>
<p>If you want to remove unused container images with just containerd, you can use the below command:</p>
<p><strong>$ <code>crictl rmi --prune</code></strong></p>
<p>Also you can use the <strong><code>$ docker image prune</code></strong> command which allows you to clean up unused images. By default, docker image prune only cleans up dangling images. A dangling image is one that is not tagged and is not referenced by any container.</p>
<p>To remove all images which are not used by existing containers, use the -a flag:</p>
<p><strong><code>$ docker image prune -a</code></strong></p>
