14 Scaling and Maintaining 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 Chapter14/SETUP/ directory with the following command:

$ kubectl apply -f SETUP -R
NOTE

14.1 Introducing ReplicaSets

14.1.1 Creating a ReplicaSet

14.1.2 Inspecting a ReplicaSet and its Pods

14.1.3 Understanding Pod ownership

14.2 Updating a ReplicaSet

14.2.1 Scaling a ReplicaSet

14.2.2 Updating the Pod template

14.3 Understanding the operation of the ReplicaSet controller

14.3.1 Introducing the reconciliation control loop

14.3.2 Understanding how the ReplicaSet controller reacts to Pod changes

14.3.3 Removing a Pod from the ReplicaSet’s control

14.4 Deleting a ReplicaSet

14.4.1 Deleting a ReplicaSet and all associated Pods

14.4.2 Deleting a ReplicaSet while preserving the Pods

14.5 Summary