5.3 Using Persistent Storage

The concept of using persistent storage for a database deployment was introduced in the previous section, Section 5.2, “Pod Configuration Using a YAML Deployment”. Persistent storage is essential when working with stateful applications like databases, as it is important that you are able to retain data beyond the lifecycle of the container, or even of the pod, itself.

Persistent storage, in Kubernetes, is handled in the form of PersistentVolume objects and are bound to pods using PersistentVolumeClaims. PersistentVolumes can be hosted locally or can be hosted on networked storage devices or services.

While it is convenient to us the hostPath persistent volume type to store data on the local disk in a demonstration or small-scale deployment, a typical Kubernetes environment involves multiple hosts and usually includes some type of networked storage. Using networked storage helps to ensure resilience and allows you to take full advantage of a clustered environment. In the case where the node where a pod is running fails, a new pod can be started on an alternate node and storage access can be resumed. This is particularly important for database environments where replica setup has been properly configured.

In this section, we continue to explore the Kubernetes components that are used to configure persistent storage, with the focus on using networked storage to host data.