liveBook · Manning

Chapter 10: Persisting data with PersistentVolumes

What you will learn in chapter 10 of Kubernetes in Action, Second Edition

This chapter introduction previews persistent storage topics, including PersistentVolumes, provisioning, snapshots, and node-local versus network-attached storage.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction previews persistent storage topics, including PersistentVolumes, provisioning, snapshots, and node-local versus network-attached storage.

10.1 Introducing persistent storage in Kubernetes

The section explains how Kubernetes lets applications request persistent storage without specifying the cluster’s storage technology or a particular volume.

Key terms: persistent storage, volume, provisions

10.1.1 Introducing PersistentVolumeClaims and PersistentVolumes

This section explains how PersistentVolumes, PersistentVolumeClaims, and StorageClasses connect pods to persistent storage, including how pods mount and share a claimed volume.

Key terms: PersistentVolume, PersistentVolumeClaim, StorageClass, provisioner, CSI driver, controller component, per-node component, persistentVolumeClaim volume type, storage technology

10.1.2 Dynamic vs. static provisioning of PersistentVolumes

This section contrasts on-demand and administrator-prepared PersistentVolumes, explaining how claims obtain them and what happens as pods and claims come and go.

Key terms: dynamic provisioning, CSI driver, CSIDriver resource, StorageClass, PersistentVolumeClaim, PersistentVolume, static provisioning, bound, released, pod

10.2 Dynamically provisioning a PersistentVolume

The section explains why the quiz Pod needs persistent storage and identifies a PersistentVolumeClaim as the first step toward using a dynamically provisioned PersistentVolume.

Key terms: emptyDir volume, PersistentVolumeClaim, dynamically provisioned PersistentVolume

10.2.1 Creating a PersistentVolumeClaim

Shows how to define a PersistentVolumeClaim’s storage requirements, create it from a manifest, and interpret its initial status.

Key terms: PersistentVolumeClaim, StorageClass, storageClassName, default StorageClass, Pending, resources.requests.storage, minimum size, dynamic provisioning, static provisioning, access mode

10.2.2 Using PersistentVolumeClaims

This section shows how a pod uses a PersistentVolumeClaim and why the claimed storage remains available after the pod is deleted and recreated.

Key terms: PersistentVolumeClaim, PersistentVolume, persistentVolumeClaim volume, claimName, Bound, detached, ephemeral, quiz Pod

10.2.3 Deleting a PersistentVolumeClaim and PersistentVolume

The section explains what happens to a PersistentVolume after its claim is deleted and how its reclaim policy affects whether the volume and data are deleted.

Key terms: PersistentVolumeClaim, PersistentVolume, Released, Available, reclaim policy, Delete, persistentVolumeReclaimPolicy, reclaimPolicy, Retain, underlying storage

10.2.4 Understanding access modes

This section explains how four PersistentVolume access modes limit which pods or nodes can use a volume, and how to populate and mount a dynamically provisioned read-only volume.

Key terms: ReadWriteOncePod, PersistentVolumeClaim, Pending, ReadWriteOnce, ContainerCreating, read-write mode, ReadWriteMany, StorageClasses, ReadOnlyMany, dataSourceRef

10.2.5 Understanding StorageClasses

Explains how StorageClasses determine the storage provisioned for a PersistentVolumeClaim and when its volume is bound.

Key terms: storageClassName, StorageClass, PersistentVolumeClaim, default, provisioner, parameters, PersistentVolume, volumeBindingMode, Immediate, WaitForFirstConsumer

10.2.6 About CSI drivers

This section explains why storage support lives in CSI drivers, what their components do, and how to identify installed drivers in a cluster.

Key terms: CSI drivers, out-of-tree, controller, per-node component, node-level agent, PersistentVolumes, StorageClass, CSIDriver resource, kubectl get, provisioner field

10.3 Statically provisioning a PersistentVolume

Introduces static provisioning as creating storage and its PersistentVolume object before a claim needs it.

Key terms: static provisioning, PersistentVolume, PersistentVolumeClaim, dynamic provisioning

10.3.1 Creating a node-local PersistentVolume

This section explains why node-local PersistentVolumes are useful and how an administrator represents local storage with a StorageClass and a pre-provisioned PersistentVolume.

Key terms: hostPath volume, local PersistentVolume, node-local PersistentVolume, StorageClass, kubernetes.io/no-provisioner, volumeBindingMode, WaitForFirstConsumer, PersistentVolume, local volume, node affinity

10.3.2 Claiming a pre-provisioned PersistentVolume

This section shows how a pod claims a pre-provisioned local PersistentVolume and explains how the same approach applies to other pre-provisioned volume types.

Key terms: PersistentVolumeClaim, PersistentVolume, local StorageClass, WaitForFirstConsumer, scheduler, pre-provisioned PersistentVolume, network-attached PersistentVolume, csi field, StorageClass

10.3.3 Releasing and recycling a manually provisioned PersistentVolume

This section explains what happens when a statically provisioned PersistentVolume is released, made reusable, or deleted while still in use.

Key terms: persistentVolumeReclaimPolicy, Retain, Released, Available, Pending, PersistentVolume object, claimRef, Bound, PersistentVolume, PersistentVolumeClaim

10.4 Managing PersistentVolumes

This section introduces upcoming topics for managing PersistentVolumes: resizing, snapshots, and restoring from a snapshot.

10.4.1 Resizing PersistentVolumeClaims

This section shows how to request a larger volume through an existing PersistentVolumeClaim and diagnose why the new capacity may not appear until its pod is recreated.

Key terms: PersistentVolumeClaim, storageClassName, spec.resources.requests, spec.resources.requests.storage, ALLOWVOLUMEEXPANSION, kubectl apply, StorageClass, kubectl get pvc, CAPACITY, kubectl describe

10.4.2 Creating a snapshot of a PersistentVolumeClaim

Explains how to request a CSI-backed snapshot of a PersistentVolumeClaim and interpret the snapshot resources and status.

Key terms: VolumeSnapshotClass, CSI driver, deletionPolicy, VolumeSnapshot, PersistentVolumeClaim, READYTOUSE, RESTORESIZE, VolumeSnapshotContent, namespaced, cluster scoped

10.4.3 Restoring a PersistentVolume from a snapshot

This section shows how to create a PersistentVolumeClaim from a VolumeSnapshot and when a pod is needed to start restoration.

Key terms: PersistentVolumeClaim, VolumeSnapshot, dataSourceRef, apiGroup, snapshot.storage.k8s.io, storageClassName, default StorageClass, WaitForFirstConsumer, volume binding policy

10.5 Creating ephemeral PersistentVolumes for individual pods

Introduces ephemeral PersistentVolumes by contrasting them with the chapter’s usual expectation of storage independent of any particular pod.

Key terms: PersistentVolume, persistent storage, ephemeral PersistentVolume

10.5.1 Introducing the ephemeral volume type

This subsection shows how an ephemeral volume creates a pod-specific PersistentVolumeClaim, mounts its bound PersistentVolume, and is cleaned up with the pod.

Key terms: ephemeral volume, volumeClaimTemplate, PersistentVolumeClaim, PersistentVolume, ephemeral PersistentVolumeClaim, life cycle, retain policy, Delete

10.5.2 Understanding the benefits of using an ephemeral volume

This section explains why a pod might use an ephemeral volume instead of an emptyDir volume for temporary data.

Key terms: ephemeral volume, emptyDir volume, scratch data, volumeClaimTemplate, PersistentVolumeClaim, PersistentVolume, snapshots

10.6 Summary

Summarizes how Kubernetes provisions, uses, and manages PersistentVolumes, including local and ephemeral volumes.

Where this is used later

Concepts explained in this chapter

← Chapter 9: Adding volumes for storage, configuration, and metadata Chapter 11: Exposing pods with services →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.