Chapter 10. StatefulSets: deploying replicated stateful applications

 

This chapter covers

  • Deploying stateful clustered applications
  • Providing separate storage for each instance of a replicated pod
  • Guaranteeing a stable name and hostname for pod replicas
  • Starting and stopping pod replicas in a predictable order
  • Discovering peers through DNS SRV records

You now know how to run both single-instance and replicated stateless pods, and even stateful pods utilizing persistent storage. You can run several replicated web-server pod instances and you can run a single database pod instance that uses persistent storage, provided either through plain pod volumes or through Persistent-Volumes bound by a PersistentVolumeClaim. But can you employ a ReplicaSet to replicate the database pod?

10.1. Replicating stateful pods

ReplicaSets create multiple pod replicas from a single pod template. These replicas don’t differ from each other, apart from their name and IP address. If the pod template includes a volume, which refers to a specific PersistentVolumeClaim, all replicas of the ReplicaSet will use the exact same PersistentVolumeClaim and therefore the same PersistentVolume bound by the claim (shown in figure 10.1).

Figure 10.1. All pods from the same ReplicaSet always use the same PersistentVolumeClaim and PersistentVolume.

10.1.1. Running multiple replicas with separate storage for each

10.1.2. Providing a stable identity for each pod

10.2. Understanding StatefulSets

10.2.1. Comparing StatefulSets with ReplicaSets

10.2.2. Providing a stable network identity

10.2.3. Providing stable dedicated storage to each stateful instance

10.2.4. Understanding StatefulSet guarantees

10.3. Using a StatefulSet

10.3.1. Creating the app and container image

10.3.2. Deploying the app through a StatefulSet

10.3.3. Playing with your pods

10.4. Discovering peers in a StatefulSet

10.4.1. Implementing peer discovery through DNS

10.4.2. Updating a StatefulSet

10.4.3. Trying out your clustered data store

10.5. Understanding how StatefulSets deal with node failures

10.5.1. Simulating a node’s disconnection from the network

10.5.2. Deleting the pod manually

10.6. Summary

sitemap