10 Persisting Data with PersistentVolumes

 

This chapter covers

  • Using PersistentVolume objects to represent persistent storage
  • Claiming PersistentVolumes with PersistentVolumeClaims
  • Static and dynamic provisioning of PersistentVolumes
  • Node-local versus network-attached storage
  • Snapshotting, cloning, and restoring volumes using the VolumeSnapshot resource
  • Long-lived versus ephemeral PersistentVolumes

The previous chapter taught you how to mount ephemeral storage volumes into your Pods. In this chapter, you’ll learn how to do the same for persistent storage volumes, which can be either node-local or network-attached.

Note

10.1 Introducing persistent storage in Kubernetes

Ideally, a developer deploying their applications on Kubernetes shouldn’t need to know what storage technology the cluster provides, just as they don’t need to know the properties of physical servers running the Pods. Infrastructure details should be managed by the people who operate the cluster.

For this reason, when deploying an application on Kubernetes, you typically don’t refer to a specific persistent storage volume. Instead, you specify that you need persistent storage with certain properties, and the cluster either finds an existing volume that matches those properties or provisions a new one.

10.1.1 Introducing PersistentVolumeClaims and PersistentVolumes

10.1.2 Dynamic vs. Static provisioning of PersistentVolumes

10.2 Dynamically provisioning a PersistentVolume

10.2.1 Creating a PersistentVolumeClaim

10.2.2 Using PersistentVolumeClaims

10.2.3 Deleting a PersistentVolumeClaim and PersistentVolume

10.2.4 Understanding access modes

10.2.5 Understanding StorageClasses

10.2.6 About CSI drivers

10.3 Statically provisioning a PersistentVolume

10.3.1 Creating a node-local PersistentVolume

10.3.2 Claiming a pre-provisioned PersistentVolume

10.3.3 Releasing and recycling a manually provisioned PersistentVolume

10.4 Managing PersistentVolumes

10.4.1 Resizing PersistentVolumeClaims

10.4.2 Creating a snapshot of a PersistentVolumeClaim

10.4.3 Restoring a PersistentVolume from a snapshot

10.5 Creating ephemeral PersistentVolumes for individual Pods

10.5.1 Introducing the ephemeral volume type

10.5.2 Understanding the benefits of using an ephemeral volume

10.6 Summary