<p>I create some pods with containers for which I set <code>ephemeral-storage</code> request and limit, like: (here <code>10GB</code>)</p>
<p><a href="https://i.stack.imgur.com/87ew4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/87ew4.png" alt="enter image description here" /></a></p>
<p>Unfortunately, for some containers, the <code>ephemeral-storage</code> will be fully filled for unknown reasons. I would like to understand which dirs/files are responsible for filling it all, but I did not find a solution to do it.</p>
<p>I tried with <code>df -h</code>, but unfortunately, it will give stats for the whole node and not only for the particular pod/container.</p>
<p>Is there a way to retrieve the kubernetes container's <code>ephemeral-storage</code> usage details?</p>

<p>Pods use ephemeral local storage for scratch space, caching, and for logs. The kubelet can provide scratch space to Pods using local ephemeral storage to mount emptyDir volumes into containers.</p>
<p>Depending on your Kubernetes platform, <strong>You may not be able to easily determine where these files are being written, any filesystem can fill up, but rest assured that disk is being consumed somewhere</strong> (or worse, memory - depending on the specific configuration of your emptyDir and/or Kubernetes platform).</p>
<p>Refer to this <a href="https://stackoverflow.com/questions/70931881"><strong>SO</strong></a> link for more details on how by default &amp; allocatable ephemeral-storage in a standard kubernetes environment is sourced from filesystem(mounted to /var/lib/kubelet).</p>
<p>And also refer to kubernetes documentation on how <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#local-ephemeral-storage" rel="nofollow noreferrer">ephemeral storage can be managed</a> &amp;  <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-emphemeralstorage-consumption" rel="nofollow noreferrer">Ephemeral storage consumption management works</a>.</p>
<p><strong>I am assuming you're a GCP user, you can get a sense of your ephemeral-storage usage way:</strong>
Menu&gt;Monitoring&gt;Metrics Explorer&gt;
Resource type: <code>kubernetes node</code> &amp; Metric: <code>Ephemeral Storage</code></p>
<p><strong>Try the below commands to know kubernetes pod/container's ephemeral-storage usage details :</strong></p>
<ol>
<li>Try <strong>du -sh</strong> / [run inside a container] : du -sh will give the space consumed by your container files. Which simply returns the amount of disk space the current directory and all those stuff in it are using as a whole, something like: 2.4G.</li>
</ol>
<p>Also you can check the complete file size using the <strong>du -h someDir</strong> command.</p>
<p><a href="https://i.stack.imgur.com/ptxQT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ptxQT.png" alt="enter image description here" /></a></p>
<ol start="2">
<li><a href="https://blog.px.dev/container-filesystems/" rel="nofollow noreferrer">Inspecting container filesystems</a> :  You can use <strong>/bin/df</strong> as a tool to monitor <a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-emphemeralstorage-consumption" rel="nofollow noreferrer">ephemeral storage usage</a> on the volume where ephemeral container data is located, which is /var/lib/kubelet and /var/lib/containers.</li>
</ol>
