Updated on 2026-06-08 GMT+08:00

Ephemeral Volume Overview

An emptyDir volume is a type of storage designed for applications that require additional storage space but do not care whether data is retained after a container restarts. This type of volume is strongly bound to the lifecycle of a pod. It is allocated when the pod is created and completely destroyed when the pod is stopped or deleted.

Typical Application Scenarios

  • Cache and temporary computing: Infrequently-used data is transferred to ephemeral storage to relieve memory pressure, or intermediate computing results are stored in ephemeral storage during the processing of large amounts of data.
  • Read-only data injection: Configuration files or secret credentials are injected into a pod as files using ConfigMaps or secrets.
  • Memory medium acceleration: Memory is used as the underlying medium to provide temporary read/write space with ultra-low latency and high throughput for applications.
  • Large image and massive log flushing (space expansion): By default, CCI provides 30 GiB of free ephemeral storage (shared with the system disk) for each pod. If the decompressed service image is too large or the application needs to write a large amount of temporary data to rootfs and emptyDir, you can configure parameters for capacity expansion to meet service requirements.

Key Parameters

When using YAML to create a workload that uses ephemeral storage, you need to accurately configure the following two types of parameters:

  • emptyDir volume parameters:
    • medium: specifies the underlying storage medium. If this parameter is an empty string, common disks are used by default. If this parameter is set to Memory, the physical memory is used as the storage medium, providing extremely fast reads and writes.
    • sizeLimit: specifies the capacity limit of the ephemeral volume. This parameter is valid only when medium is set to Memory. If this parameter is not configured, the memory may be used without restriction.
  • Parameter for expanding the ephemeral storage space (extraEphemeralStorage):
    • sizeInGiB: specifies the additional capacity to be added on top of the default 30 GiB.
    • Value range: The value must be an integer ranging from 0 to 994 (unit: GiB).

High-Risk Operations

  • Permanent data loss: Ephemeral storage volumes are not persistent. Once a pod is stopped, restarted, or deleted, the data written to the ephemeral volume will be permanently cleared. Do not store core service data in such volumes.
  • Out of memory (OOM): When emptyDir.medium is set to Memory, the memory occupied by the volume is deducted from the total memory requested by the pod. If the memory requested by the processes in the container plus the amount of data written to the volume exceeds the pod memory limit, an OOM exception occurs, causing the container to crash. You are advised to set sizeLimit to about 50% of the pod memory request.
  • Instance startup delay: When you configure extraEphemeralStorage to expand the storage space, the underlying system needs to allocate and mount disk resources, which takes time. For this reason, the creation and startup of a workload configured with capacity expansion is slightly slower than that of a workload without capacity expansion configured.