9 Stateful applications

 

This chapter covers

  • The Kubernetes constructs used to represent disks and state
  • Adding persistent storage to Pods
  • Deploying a multiple-Pod stateful application with a leader role using StatefulSet
  • Migrating and recovering data by relinking Kubernetes objects to disk resources
  • Giving Pods large ephemeral storage volumes

Stateful applications (i.e., workloads that have attached storage) finally have a home with Kubernetes. While stateless applications are often lauded for their ease of deployment and high scalability, helped greatly by avoiding the need to attach and manage storage, that doesn’t mean that stateful applications don’t have their place. Whether you’re deploying a sophisticated database or are migrating an old stateful application from a virtual machine (VM), Kubernetes has you covered.

Using persistent volumes, you can attach stateful storage to any Kubernetes Pod. When it comes to multi-replica workloads with state, just as Kubernetes offers Deployment as a high-level construct for managing a stateless application, StatefulSet exists to provide high-level management of stateful applications.

9.1 Volumes, persistent volumes, claims, and storage classes

To get started with storing state in Kubernetes, there are a few concepts around volume (disk) management to cover before moving on to the higher-level StatefulSet construct. Just like nodes are the Kubernetes representation of a VM, Kubernetes has its own representation of disks as well.

9.1.1 Volumes

9.1.2 Persistent volumes and claims

9.1.3 Storage classes

9.1.4 Single-Pod stateful workload deployments

9.2 StatefulSet

9.2.1 Deploying StatefulSet

9.2.2 Deploying a multirole StatefulSet

9.3 Migrating/recovering disks

9.4 Generic ephemeral volume for scratch space

Summary

sitemap