Lesson 4 · Core objects & the control plane
Deployments & ReplicaSets
The controllers that make ephemeral Pods reliable — keep N alive, and roll out new versions with zero downtime.
Your win: explain the Pod → ReplicaSet → Deployment hierarchy, how self-healing and rolling updates work, and why this is how ~22 of this repo's services run.
The hierarchy that fixes ephemeral Pods
Lesson 3 left a problem: Pods die and don't come back. Two nested controllers solve it:1
- A ReplicaSet's entire job: keep a specified number of identical Pods running. Fewer than desired → it creates more; more → it deletes some. This is Lesson 1's reconcile loop, applied to a replica count.2
- A Deployment manages ReplicaSets to give you declarative updates: change the image and it orchestrates the transition — rolling update, rollback, scaling.1
The rolling update — zero downtime, from first principles
When you change a Deployment's pod template (say, a new image tag), it doesn't kill everything and restart. It creates a new ReplicaSet and shifts capacity gradually:3
The pace is bounded by maxSurge (how many extra Pods above desired) and
maxUnavailable (how many below). Readiness probes (Lesson 8) gate it: a new Pod
only receives traffic once it reports ready, so users never hit a booting Pod. Rollback is
just "scale the old ReplicaSet back up" — which is why the old one is kept.
util.app orchestrator, _app.tpl:7).
spike, usermgmt, eureka, notificationmgmt
… all Deployments. And Course 1's sk.bash -s bob ended in
kubectl rollout restart deploy/bob — that command triggers exactly this
rolling-update dance.
{name}-consumers Deployment for its Kafka consumers, scaled
independently (you'll meet its KEDA autoscaler in Lesson 9). Good proof that "one service"
can be several Deployments. Not everything is a Deployment, though: tom and
conversationmgmt are StatefulSets — the subject of Lesson 7.
Kubernetes docs — Deployments (+ the rolling-update tutorial)
Declarative updates, rollouts and rollbacks, and how the Deployment drives ReplicaSets.
→ kubernetes.io — Deployments
→ kubernetes.io — Performing a rolling update
Check yourself (from memory)
Q1. The correct management hierarchy is…
Q2. A ReplicaSet's single responsibility is to…
Q3. A rolling update achieves zero downtime by…
maxSurge/maxUnavailable), readiness probes gate traffic so users
never hit a booting pod; the old RS is kept for instant ROLLBACK. You declare only the
Deployment. Repo: ~22 backend services are Deployments from
libs/util/…/_deployment.tpl:30; kubectl rollout restart deploy/bob
(Course 1) triggers the dance; notification has an extra -consumers Deployment.conversationmgmt!), and probes/resources.