chapter thirteen

13 Replicating Pods with ReplicaSets

 

This chapter covers

  • Replicating Pods with the ReplicaSet object
  • Keeping Pods running when cluster nodes fail
  • The reconciliation control loop in Kubernetes controllers
  • API Object ownership and garbage collection

So far in this book, you’ve deployed workloads by creating Pod objects directly. In a production cluster, you might need to deploy dozens or even hundreds of copies of the same Pod, so creating and managing those Pods would be difficult. Fortunately, in Kubernetes, you can automate the creation and management of Pod replicas with the ReplicaSet object.

Note

Before ReplicaSets were introduced, similar functionality was provided by the ReplicationController object type, which is now deprecated. A ReplicationController behaves exactly like a ReplicaSet, so everything that’s explained in this chapter also applies to ReplicationControllers.

Before you begin, make sure that the Pods, Services, and other objects of the Kiada suite are present in your cluster. If you followed the exercises in the previous chapter, they should already be there. If not, you can create them by creating the kiada namespace and applying all the manifests in the Chapter13/SETUP/ directory with the following command:

$ kubectl apply -f SETUP -R
NOTE

13.1 Introducing ReplicaSets

13.1.1 Creating a ReplicaSet

13.1.2 Inspecting a ReplicaSet and its Pods

13.1.3 Understanding Pod ownership

13.2 Updating a ReplicaSet

13.2.1 Scaling a ReplicaSet

13.2.2 Updating the Pod template

13.3 Understanding the operation of the ReplicaSet controller

13.3.1 Introducing the reconciliation control loop

13.3.2 Understanding how the ReplicaSet controller reacts to Pod changes

13.3.3 Removing a Pod from the ReplicaSet’s control

13.4 Deleting a ReplicaSet

13.4.1 Deleting a ReplicaSet and all associated Pods

13.4.2 Deleting a ReplicaSet while preserving the Pods

13.5 Summary