The fact that the whole space (/
) is visible to you doesn't mean that the space is available/allocatable.
Kubelet
will monitor the usage of the ephemeral storage of your Pod
and act accordingly (by evicting the Pod
that exceeded the limit):
Ephemeral storage consumption management
If the kubelet is managing local ephemeral storage as a resource, then the kubelet measures storage use in:
emptyDir
volumes, except tmpfs emptyDir
volumes
- directories holding node-level logs
- writeable container layers
If a Pod is using more ephemeral storage than you allow it to, the kubelet sets an eviction signal that triggers Pod eviction.
-- Kubernetes.io: Docs: Concepts: Configuration: Manage resources containers: Resource ephemeral storage consumption
Please take a look on below example:
Assuming that you have a following Pod
manifest:
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
resources:
requests:
ephemeral-storage: "2Gi"
limits:
ephemeral-storage: "4Gi"
The limit that is configured for ephemeral storage is 4Gi
. To check what will happen you can run:
kubectl exec -it nginx -- fallocate -l 10GB /evict.img
A side note!
fallocate
is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it.
-- Man7.org: Linux: Man pages: Fallocate
After some time you should see:
$ kubectl describe pod nginx
Name: nginx
Namespace: default
Priority: 0
Node: XYZ
Start Time: Mon, 05 Jul 2021 09:47:08 +0200
Labels: <none>
Annotations: <none>
Status: Failed # <-- IMPORTANT!
Reason: Evicted # <-- IMPORTANT!
Message: Pod ephemeral local storage usage exceeds the total limit of containers 4Gi. # <-- IMPORTANT!
<-- REDACTED -->
Limits:
ephemeral-storage: 4Gi # <-- IMPORTANT!
Requests:
ephemeral-storage: 2Gi
<-- REDACTED -->
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 32s default-scheduler Successfully assigned default/nginx to XYZ
Normal Pulling 31s kubelet Pulling image "nginx"
Normal Pulled 31s kubelet Successfully pulled image "nginx" in 360.098619ms
Normal Created 31s kubelet Created container nginx
Normal Started 31s kubelet Started container nginx
Warning Evicted 3s kubelet Pod ephemeral local storage usage exceeds the total limit of containers 4Gi. # <-- IMPORTANT!
Normal Killing 3s kubelet Stopping container nginx # <-- IMPORTANT!
NAME READY STATUS RESTARTS AGE
nginx 0/1 Evicted 0 9m7s
Additional resources: