Skip to content

Commit eea493b

Browse files
committed
Move ephemeral storage contents out of container resource page
1 parent 93fcff4 commit eea493b

File tree

2 files changed

+306
-291
lines changed

2 files changed

+306
-291
lines changed

content/en/docs/concepts/configuration/manage-resources-containers.md

Lines changed: 7 additions & 291 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ limits you defined.
268268
as restartable, Kubernetes restarts the container.
269269
- The memory limit for the Pod or container can also apply to pages in memory backed
270270
volumes, such as an `emptyDir`. The kubelet tracks `tmpfs` emptyDir volumes as container
271-
memory use, rather than as local ephemeral storage. When using memory backed `emptyDir`,
271+
memory use, rather than as local [ephemeral storage](/docs/concepts/storage/ephemeral-storage/).
272+
When using memory backed `emptyDir`,
272273
be sure to check the notes [below](#memory-backed-emptydir).
273274

274275
If a container exceeds its memory request and the node that it runs on becomes short of
@@ -337,295 +338,10 @@ As an alternative, a cluster administrator can enforce size limits for
337338

338339
## Local ephemeral storage
339340

340-
<!-- feature gate LocalStorageCapacityIsolation -->
341-
{{< feature-state for_k8s_version="v1.25" state="stable" >}}
342-
343-
Nodes have local ephemeral storage, backed by
344-
locally-attached writeable devices or, sometimes, by RAM.
345-
"Ephemeral" means that there is no long-term guarantee about durability.
346-
347-
Pods use ephemeral local storage for scratch space, caching, and for logs.
348-
The kubelet can provide scratch space to Pods using local ephemeral storage to
349-
mount [`emptyDir`](/docs/concepts/storage/volumes/#emptydir)
350-
{{< glossary_tooltip term_id="volume" text="volumes" >}} into containers.
351-
352-
The kubelet also uses this kind of storage to hold
353-
[node-level container logs](/docs/concepts/cluster-administration/logging/#logging-at-the-node-level),
354-
container images, and the writable layers of running containers.
355-
356-
{{< caution >}}
357-
If a node fails, the data in its ephemeral storage can be lost.
358-
Your applications cannot expect any performance SLAs (disk IOPS for example)
359-
from local ephemeral storage.
360-
{{< /caution >}}
361-
362-
363-
{{< note >}}
364-
To make the resource quota work on ephemeral-storage, two things need to be done:
365-
366-
* An admin sets the resource quota for ephemeral-storage in a namespace.
367-
* A user needs to specify limits for the ephemeral-storage resource in the Pod spec.
368-
369-
If the user doesn't specify the ephemeral-storage resource limit in the Pod spec,
370-
the resource quota is not enforced on ephemeral-storage.
371-
372-
{{< /note >}}
373-
374-
Kubernetes lets you track, reserve and limit the amount
375-
of ephemeral local storage a Pod can consume.
376-
377-
### Configurations for local ephemeral storage
378-
379-
Kubernetes supports two ways to configure local ephemeral storage on a node:
380-
{{< tabs name="local_storage_configurations" >}}
381-
{{% tab name="Single filesystem" %}}
382-
In this configuration, you place all different kinds of ephemeral local data
383-
(`emptyDir` volumes, writeable layers, container images, logs) into one filesystem.
384-
The most effective way to configure the kubelet means dedicating this filesystem
385-
to Kubernetes (kubelet) data.
386-
387-
The kubelet also writes
388-
[node-level container logs](/docs/concepts/cluster-administration/logging/#logging-at-the-node-level)
389-
and treats these similarly to ephemeral local storage.
390-
391-
The kubelet writes logs to files inside its configured log directory (`/var/log`
392-
by default); and has a base directory for other locally stored data
393-
(`/var/lib/kubelet` by default).
394-
395-
Typically, both `/var/lib/kubelet` and `/var/log` are on the system root filesystem,
396-
and the kubelet is designed with that layout in mind.
397-
398-
Your node can have as many other filesystems, not used for Kubernetes,
399-
as you like.
400-
{{% /tab %}}
401-
{{% tab name="Two filesystems" %}}
402-
You have a filesystem on the node that you're using for ephemeral data that
403-
comes from running Pods: logs, and `emptyDir` volumes. You can use this filesystem
404-
for other data (for example: system logs not related to Kubernetes); it can even
405-
be the root filesystem.
406-
407-
The kubelet also writes
408-
[node-level container logs](/docs/concepts/cluster-administration/logging/#logging-at-the-node-level)
409-
into the first filesystem, and treats these similarly to ephemeral local storage.
410-
411-
You also use a separate filesystem, backed by a different logical storage device.
412-
In this configuration, the directory where you tell the kubelet to place
413-
container image layers and writeable layers is on this second filesystem.
414-
415-
The first filesystem does not hold any image layers or writeable layers.
416-
417-
Your node can have as many other filesystems, not used for Kubernetes,
418-
as you like.
419-
{{% /tab %}}
420-
{{< /tabs >}}
421-
422-
The kubelet can measure how much local storage it is using. It does this provided
423-
that you have set up the node using one of the supported configurations for local
424-
ephemeral storage.
425-
426-
If you have a different configuration, then the kubelet does not apply resource
427-
limits for ephemeral local storage.
428-
429-
{{< note >}}
430-
The kubelet tracks `tmpfs` emptyDir volumes as container memory use, rather
431-
than as local ephemeral storage.
432-
{{< /note >}}
433-
434-
{{< note >}}
435-
The kubelet will only track the root filesystem for ephemeral storage. OS layouts that mount a separate disk to `/var/lib/kubelet` or `/var/lib/containers` will not report ephemeral storage correctly.
436-
{{< /note >}}
437-
438-
### Setting requests and limits for local ephemeral storage
439-
440-
You can specify `ephemeral-storage` for managing local ephemeral storage. Each
441-
container of a Pod can specify either or both of the following:
442-
443-
* `spec.containers[].resources.limits.ephemeral-storage`
444-
* `spec.containers[].resources.requests.ephemeral-storage`
445-
446-
Limits and requests for `ephemeral-storage` are measured in byte quantities.
447-
You can express storage as a plain integer or as a fixed-point number using one of these suffixes:
448-
E, P, T, G, M, k. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi,
449-
Mi, Ki. For example, the following quantities all represent roughly the same value:
450-
451-
- `128974848`
452-
- `129e6`
453-
- `129M`
454-
- `123Mi`
455-
456-
Pay attention to the case of the suffixes. If you request `400m` of ephemeral-storage, this is a request
457-
for 0.4 bytes. Someone who types that probably meant to ask for 400 mebibytes (`400Mi`)
458-
or 400 megabytes (`400M`).
459-
460-
In the following example, the Pod has two containers. Each container has a request of
461-
2GiB of local ephemeral storage. Each container has a limit of 4GiB of local ephemeral
462-
storage. Therefore, the Pod has a request of 4GiB of local ephemeral storage, and
463-
a limit of 8GiB of local ephemeral storage. 500Mi of that limit could be
464-
consumed by the `emptyDir` volume.
465-
466-
```yaml
467-
apiVersion: v1
468-
kind: Pod
469-
metadata:
470-
name: frontend
471-
spec:
472-
containers:
473-
- name: app
474-
image: images.my-company.example/app:v4
475-
resources:
476-
requests:
477-
ephemeral-storage: "2Gi"
478-
limits:
479-
ephemeral-storage: "4Gi"
480-
volumeMounts:
481-
- name: ephemeral
482-
mountPath: "/tmp"
483-
- name: log-aggregator
484-
image: images.my-company.example/log-aggregator:v6
485-
resources:
486-
requests:
487-
ephemeral-storage: "2Gi"
488-
limits:
489-
ephemeral-storage: "4Gi"
490-
volumeMounts:
491-
- name: ephemeral
492-
mountPath: "/tmp"
493-
volumes:
494-
- name: ephemeral
495-
emptyDir:
496-
sizeLimit: 500Mi
497-
```
498-
499-
### How Pods with ephemeral-storage requests are scheduled
500-
501-
When you create a Pod, the Kubernetes scheduler selects a node for the Pod to
502-
run on. Each node has a maximum amount of local ephemeral storage it can provide for Pods.
503-
For more information, see
504-
[Node Allocatable](/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable).
505-
506-
The scheduler ensures that the sum of the resource requests of the scheduled containers is less than the capacity of the node.
507-
508-
### Ephemeral storage consumption management {#resource-emphemeralstorage-consumption}
509-
510-
If the kubelet is managing local ephemeral storage as a resource, then the
511-
kubelet measures storage use in:
512-
513-
- `emptyDir` volumes, except _tmpfs_ `emptyDir` volumes
514-
- directories holding node-level logs
515-
- writeable container layers
516-
517-
If a Pod is using more ephemeral storage than you allow it to, the kubelet
518-
sets an eviction signal that triggers Pod eviction.
519-
520-
For container-level isolation, if a container's writable layer and log
521-
usage exceeds its storage limit, the kubelet marks the Pod for eviction.
522-
523-
For pod-level isolation the kubelet works out an overall Pod storage limit by
524-
summing the limits for the containers in that Pod. In this case, if the sum of
525-
the local ephemeral storage usage from all containers and also the Pod's `emptyDir`
526-
volumes exceeds the overall Pod storage limit, then the kubelet also marks the Pod
527-
for eviction.
528-
529-
{{< caution >}}
530-
If the kubelet is not measuring local ephemeral storage, then a Pod
531-
that exceeds its local storage limit will not be evicted for breaching
532-
local storage resource limits.
533-
534-
However, if the filesystem space for writeable container layers, node-level logs,
535-
or `emptyDir` volumes falls low, the node
536-
{{< glossary_tooltip text="taints" term_id="taint" >}} itself as short on local storage
537-
and this taint triggers eviction for any Pods that don't specifically tolerate the taint.
538-
539-
See the supported [configurations](#configurations-for-local-ephemeral-storage)
540-
for ephemeral local storage.
541-
{{< /caution >}}
542-
543-
The kubelet supports different ways to measure Pod storage use:
544-
545-
{{< tabs name="resource-emphemeralstorage-measurement" >}}
546-
{{% tab name="Periodic scanning" %}}
547-
The kubelet performs regular, scheduled checks that scan each
548-
`emptyDir` volume, container log directory, and writeable container layer.
549-
550-
The scan measures how much space is used.
551-
552-
{{< note >}}
553-
In this mode, the kubelet does not track open file descriptors
554-
for deleted files.
555-
556-
If you (or a container) create a file inside an `emptyDir` volume,
557-
something then opens that file, and you delete the file while it is
558-
still open, then the inode for the deleted file stays until you close
559-
that file but the kubelet does not categorize the space as in use.
560-
{{< /note >}}
561-
{{% /tab %}}
562-
{{% tab name="Filesystem project quota" %}}
563-
564-
{{< feature-state feature_gate_name="LocalStorageCapacityIsolationFSQuotaMonitoring" >}}
565-
566-
Project quotas are an operating-system level feature for managing
567-
storage use on filesystems. With Kubernetes, you can enable project
568-
quotas for monitoring storage use. Make sure that the filesystem
569-
backing the `emptyDir` volumes, on the node, provides project quota support.
570-
For example, XFS and ext4fs offer project quotas.
571-
572-
{{< note >}}
573-
Project quotas let you monitor storage use; they do not enforce limits.
574-
{{< /note >}}
575-
576-
Kubernetes uses project IDs starting from `1048576`. The IDs in use are
577-
registered in `/etc/projects` and `/etc/projid`. If project IDs in
578-
this range are used for other purposes on the system, those project
579-
IDs must be registered in `/etc/projects` and `/etc/projid` so that
580-
Kubernetes does not use them.
581-
582-
Quotas are faster and more accurate than directory scanning. When a
583-
directory is assigned to a project, all files created under a
584-
directory are created in that project, and the kernel merely has to
585-
keep track of how many blocks are in use by files in that project.
586-
If a file is created and deleted, but has an open file descriptor,
587-
it continues to consume space. Quota tracking records that space accurately
588-
whereas directory scans overlook the storage used by deleted files.
589-
590-
To use quotas to track a pod's resource usage, the pod must be in
591-
a user namespace. Within user namespaces, the kernel restricts changes
592-
to projectIDs on the filesystem, ensuring the reliability of storage
593-
metrics calculated by quotas.
594-
595-
If you want to use project quotas, you should:
596-
597-
* Enable the `LocalStorageCapacityIsolationFSQuotaMonitoring=true`
598-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
599-
using the `featureGates` field in the
600-
[kubelet configuration](/docs/reference/config-api/kubelet-config.v1beta1/).
601-
602-
* Ensure the `UserNamespacesSupport`
603-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
604-
is enabled, and that the kernel, CRI implementation and OCI runtime support user namespaces.
605-
606-
* Ensure that the root filesystem (or optional runtime filesystem)
607-
has project quotas enabled. All XFS filesystems support project quotas.
608-
For ext4 filesystems, you need to enable the project quota tracking feature
609-
while the filesystem is not mounted.
610-
611-
```bash
612-
# For ext4, with /dev/block-device not mounted
613-
sudo tune2fs -O project -Q prjquota /dev/block-device
614-
```
615-
616-
* Ensure that the root filesystem (or optional runtime filesystem) is
617-
mounted with project quotas enabled. For both XFS and ext4fs, the
618-
mount option is named `prjquota`.
619-
620-
621-
If you don't want to use project quotas, you should:
622-
623-
* Disable the `LocalStorageCapacityIsolationFSQuotaMonitoring`
624-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
625-
using the `featureGates` field in the
626-
[kubelet configuration](/docs/reference/config-api/kubelet-config.v1beta1/).
627-
{{% /tab %}}
628-
{{< /tabs >}}
341+
For general concepts about local ephemeral storage and hints about
342+
configuring the requests and/or limits of ephemeral storage for a container,
343+
please check the [local ephemeral storage](/docs/concepts/storage/ephemeral-storage/)
344+
page.
629345

630346
## Extended resources
631347

@@ -940,7 +656,7 @@ memory limit (and possibly request) for that container.
940656
* Get hands-on experience [assigning CPU resources to containers and Pods](/docs/tasks/configure-pod-container/assign-cpu-resource/).
941657
* Read how the API reference defines a [container](/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container)
942658
and its [resource requirements](/docs/reference/kubernetes-api/workload-resources/pod-v1/#resources)
943-
* Read about [project quotas](https://www.linux.org/docs/man8/xfs_quota.html) in XFS
659+
* Read more about the [local ephemeral storage](/docs/concepts/storage/ephemeral-storage/)
944660
* Read more about the [kube-scheduler configuration reference (v1)](/docs/reference/config-api/kube-scheduler-config.v1/)
945661
* Read more about [Quality of Service classes for Pods](/docs/concepts/workloads/pods/pod-qos/)
946662
* Read more about [Extended Resource allocation by DRA](/docs/concepts/scheduling-eviction/dynamic-resource-allocation/#extended-resource)

0 commit comments

Comments
 (0)