chapter eight

8 Persisting application data with PersistentVolumes

 

This chapter covers

  • Using PersistentVolume objects to represent persistent storage
  • Claiming persistent volumes with PersistentVolumeClaim objects
  • Dynamic provisioning of persistent volumes
  • Using node-local persistent storage

The previous chapter taught you how to mount a network storage volume into your pods. However, the experience was not ideal because you needed to understand the environment your cluster was running in to know what type of volume to add to your pod. For example, if your cluster runs on Google’s infrastructure, you must define a gcePersistentDisk volume in your pod manifest. You can’t use the same manifest to run your application on Amazon because GCE Persistent Disks aren’t supported in their environment. To make the manifest compatible with Amazon, one must modify the volume definition in the manifest before deploying the pod.

You may remember from chapter 1 that Kubernetes is supposed to standardize application deployment between cloud providers. Using proprietary storage volume types in pod manifests goes against this premise.

Fortunately, there is a better way to add persistent storage to your pods. One where you don’t refer to a specific storage technology within the pod. This chapter explains this improved approach.

Note

8.1 Decoupling pods from the underlying storage technology

8.1.1 Introducing persistent volumes and claims

8.1.2 Understanding the benefits of using persistent volumes and claims

8.2 Creating persistent volumes and claims

8.2.1 Creating a PersistentVolume object

8.2.2 Claiming a persistent volume

8.2.3 Using a claim and volume in a single pod

8.2.4 Using a claim and volume in multiple pods

8.2.5 Understanding the lifecycle of manually provisioned persistent volumes

8.3 Dynamic provisioning of persistent volumes

8.3.1 Introducing the StorageClass object

8.3.2 Dynamic provisioning using the default storage class

8.3.3 Creating a storage class and provisioning volumes of that class

8.3.4 Resizing persistent volumes

8.3.5 Understanding the benefits of dynamic provisioning

8.3.6 Understanding the lifecycle of dynamically provisioned persistent volumes

8.4 Node-local persistent volumes

8.4.1 Creating local persistent volumes

8.4.2 Claiming and using local persistent volumes

8.5 Summary