liveBook · Manning

Chapter 14: Scaling and maintaining pods with ReplicaSets

What you will learn in chapter 14 of Kubernetes in Action, Second Edition

The chapter introduces ReplicaSets as a way to automate the creation and management of many copies of a pod.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces ReplicaSets as a way to automate the creation and management of many copies of a pod.

Key terms: Pod objects, pod replicas, ReplicaSet object, ReplicationController, ReplicaSet, deprecated

14.1 Introducing ReplicaSets

This section introduces ReplicaSets as a way to create and maintain pod replicas, while distinguishing their role from Services and Deployments.

Key terms: ReplicaSet, Pod template, replicas, label selector, pod labels, Service object, Deployment, declaratively

14.1.1 Creating a ReplicaSet

Shows how to replace three separately defined Kiada pods with a ReplicaSet manifest and explains the key requirements of its spec.

Key terms: ReplicaSet, spec, selector, template, replicas, labels, Pod template, desired number of replicas, Kiada, apps API group

14.1.2 Inspecting a ReplicaSet and its pods

This section shows how to inspect a ReplicaSet and its pods, understand their names, and view their logs.

Key terms: kubectl get, -o wide, kubectl describe, readyReplicas, Pod template, label selector, kubectl get pods, adopted, replicas, generateName

14.1.3 Understanding pod ownership

Explains how a pod records its ReplicaSet owner, how that ownership affects deletion, and why the pod should be managed through the ReplicaSet.

Key terms: ownerReferences, owner, dependent, garbage collector, controller: true, ReplicaSet, controlled

14.2 Updating a ReplicaSet

This section identifies which ReplicaSet properties can be updated and explains that changing the desired replica count scales the ReplicaSet.

Key terms: desired number of replicas, Pod template, label selector, immutable, scale

14.2.1 Scaling a ReplicaSet

This subsection shows how to change a ReplicaSet’s replica count, explains which pods are removed when scaling down, and describes scaling to zero without deleting the ReplicaSet.

Key terms: ReplicaSet, replicas, kubectl scale, kubectl edit, pod-deletion-cost, related replicas, ready, zero replicas, ReplicaSet object

14.2.2 Updating the Pod template

Shows how to change a ReplicaSet’s Pod template and why the change affects newly created pods but not existing ones.

Key terms: Pod template, metadata.labels, selector, kubectl edit, kubectl label, ReplicaSet, scale

14.3 Understanding the operation of the ReplicaSet controller

Introduces the ReplicaSet controller as the component that processes ReplicaSet changes, adjusts pods during scaling, and records its actions as events.

Key terms: ReplicaSet controller, Event object, kubectl describe, kubectl get events

14.3.1 Introducing the reconciliation control loop

This section explains how controllers reconcile actual state with desired state, using the ReplicaSet controller’s pod-count decisions as an example.

Key terms: controller, owning object, dependent objects, desired state, reconciliation control loop, ReplicaSet controller, associated pods, desired number, Pod template, replicas

14.3.2 Understanding how the ReplicaSet controller reacts to pod changes

This section shows how a ReplicaSet restores its desired pod count after pod changes or node failure, and why that count does not guarantee healthy, ready replicas.

Key terms: ReplicaSet controller, replicas, label selector, desired state, NotReady, Kubelet, Terminating, liveness probe, readiness probe, ready

14.3.3 Removing a pod from the ReplicaSet’s control

Shows how changing a pod’s labels removes it from a ReplicaSet’s control, prompts a replacement, and leaves the original pod available for troubleshooting.

Key terms: ReplicaSet controller, label selector, replicas, rel=stable, rel=debug, ownerReferences, ReplicaSet, faulty pod

14.4 Deleting a ReplicaSet

Deleting a ReplicaSet signals that its pod replicas are no longer wanted, so the garbage collector deletes them too.

Key terms: ReplicaSet, pod replicas, garbage collector

14.4.1 Deleting a ReplicaSet and all associated pods

This subsection explains that deleting a ReplicaSet also deletes the pods it controls.

Key terms: ReplicaSet, pods it controls

14.4.2 Deleting a ReplicaSet while preserving the pods

Explains how to delete a ReplicaSet without deleting its pods, and how a new ReplicaSet can take ownership of those pods.

Key terms: label selector, orphan, ownerReferences, ReplicaSet

14.5 Summary

Summarizes how ReplicaSets define and maintain a desired number of identical pods, and what happens when their templates or ownership change.

Where this is used later

Concepts explained in this chapter

← Chapter 13: Routing traffic using the Gateway API Chapter 15: Automating application updates with Deployments →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.