This page provides an overview of Volumes in Kubernetes, and their use with Google Kubernetes Engine.


On-disk files in a container are the simplest place for an application to write data, but this approach has drawbacks. The files are lost when the container crashes or stops for any other reason. Furthermore, files within a container are inaccessible to other containers running in the same Pod. The Kubernetes Volume abstraction addresses both of these issues.

Conceptually, a volume is a directory which is accessible to all of the containers in a Pod. The volume source declared in the Pod specification determines how the directory is created, the storage medium used, and the directory's initial contents. A Pod specifies what Volumes it contains and the path where containers mount the Volume.

Ephemeral Volume types have the same lifetimes as their enclosing Pods. These Volumes are created when the Pod is created, and they persist through container restarts. When the Pod terminates or is deleted its Volumes go with it.

Other Volume types are interfaces to durable storage that exist independently of a Pod. Unlike ephemeral volumes, data in a Volume backed by durable storage is preserved when the Pod is removed. The volume is merely unmounted and the data can be handed off to another Pod. You should use PersistentVolume resources to manage the lifecycle of durable storage types, rather than directly specifying them.

Types of volumes

Volumes differ in their storage implementation and their initial contents. You can choose the Volume source that best fits your use case. Several common Volume sources are described below:

An ephemeral volume type that provides an empty directory that containers in the Pod can read and write from. When the Pod is removed from a node for any reason, the data in the emptyDir is deleted forever. emptyDirs are useful for scratch space and sharing data between multiple containers in a Pod.
Used to make configuration data accessible to applications. The files in a configMap Volume are specified by a ConfigMap resource.
Used to make sensitive data, such as passwords, OAuth tokens, and SSH keys, available to applications.
Used to make Downward API data available to applications. This data includes information about the Pod and container in which an application is running in. For example, a Pod can be configured to expose a DownwardAPIVolumeFile to applications that includes the Pod's namespace and IP address.
Cluster operators can provision durable storage to be used by applications. A Pod uses a PersistentVolumeClaim to mount a Volume that is backed by this durable storage.

For a complete list of Volume types, refer to the Kubernetes Volumes documentation.

What's next

Оцените, насколько информация на этой странице была вам полезна:

Оставить отзыв о...

Текущей странице
Kubernetes Engine Documentation