Volumnes

On-disk files in a container are ephemeral, which presents some problems for non-trivial applications when running in containers. One problem is the loss of files when a container crashes. The kubelet restarts the container but with a clean state. A second problem occurs when sharing files between containers running together in a Pod. The Kubernetes volume abstraction solves both of these problems. Familiarity with Pods is suggested.

Kubernetes supports many types of volumes. A Pod can use any number of volume types simultaneously.

  1. Ephemeral volume types have a lifetime of a pod,
  2. but persistent volumes exist beyond the lifetime of a pod.

When a pod ceases to exist, Kubernetes destroys ephemeral volumes; however, Kubernetes does not destroy persistent volumes. For any kind of volume in a given pod, data is preserved across container restarts.

At its core, a volume is a directory, possibly with some data in it, which is accessible to the containers in a pod. How that directory comes to be, the medium that backs it, and the contents of it are determined by the particular volume type used.

Volumes

Docker has a concept of volumes,

  • though it is somewhat looser and less managed.
  • A Docker volume is a directory on disk or in another container.
  • Docker provides volume drivers, but the functionality is somewhat limited. Manage Data in Docker