A web API runs across three servers. Power drops on one server, and a third of incoming requests stop reaching a working instance of the application. Who detects the lost node, where does a replacement start, how is the failed process removed from load balancing, and when can the new copy receive traffic? These operational questions remain even after the container image has been built, tested, and started manually. Orchestration solves automated placement, recovery, and coordinated upgrades across a pool of machines.
After this lesson, you will be able to explain the limits of a single host compared with a cluster, read a declarative Deployment manifest, map Desired, Existing, and Ready counts to real kubectl output, distinguish a missing Pod from a delayed readinessProbe, and separate platform ownership from application team responsibilities. If you want to review container fundamentals before diving into clusters, revisit Containers vs Virtual Machines, Why Kubernetes, and Kubernetes Pods.
1. From running a container to managing an application in a cluster
An OCI image packages application code alongside its system dependencies. On a single server, a container runtime (containerd or Docker Engine) starts an isolated container from that image. When a service consists of an API, a database, and a background worker, Docker Compose lets you define them in one file and bring them up together on a single machine. For local development and integration tests, that provides a fast, repeatable setup.
On a single server, a restart policy (restart: always) can recover a crashed process only while the server itself stays healthy. Once an application spans multiple machines for fault tolerance and higher throughput, coordination challenges appear that single-host tools do not address.
| Operational task | Single host (Docker Compose) | Cluster (Kubernetes) |
|---|---|---|
| Physical or virtual server failure | Single point of failure (SPOF): every container on the node goes down | A controller recreates missing Pods on healthy cluster nodes |
| Selecting a machine for a copy | An engineer manually picks a host with free RAM/CPU | The scheduler (kube-scheduler) automatically finds a node matching resource requests |
| Networking and load balancing | Tied to host ports and a local bridge; external load balancers require separate setup | A stable internal Service address and DNS name distribute traffic across nodes |
| Readiness verification | A container gets requests as soon as PID 1 starts, even before caches warm up | Service routes traffic only to Pods passing readinessProbe |
| Zero-downtime updates | Stopping and recreating a container drops active connections without custom scripts | Deployment swaps replicas gradually (RollingUpdate) under readiness checks |
Kubernetes groups a pool of servers into a unified cluster managed through a shared API and declarative rules. Multiple independent replicas—identical instances of the current release—can serve requests behind a single application address.
| Concept | Role in this lesson's architecture |
|---|---|
Cluster | A group of worker machines paired with the Control Plane management components |
Node | A physical or virtual machine in the cluster that runs workloads |
Pod | The smallest placement unit. Usually holds one main application container (occasionally helper containers) |
ReplicaSet | A controller that watches active Pods and maintains their requested count |
Deployment | A declarative object managing application version, replica count, and rollout strategy |
Service | A stable network entry point (internal IP and DNS name) routing ordinary traffic only to ready Pods |
In our end-to-end scenario, each Pod runs one instance of web-api. Asking to "keep three replicas" means keeping three separate Pods distributed across nodes. Clients connect via the Service DNS name: if a node fails, the replacement Pod receives a different internal IP address while the Service address stays constant.
2. Declarative state and the reconciliation loop
Working with Kubernetes revolves around declarative management. Instead of writing imperative instructions in YAML ("create a container on host two, then open a port"), an engineer declares the target Desired State: which image should run, how many replicas are needed, and how readiness is verified.
Below is a minimal declarative Deployment manifest for our web-api service. It declares the target replica count (replicas: 3), container image, and an HTTP readiness check on /healthz:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-api
spec:
replicas: 3
selector:
matchLabels:
app: web-api
template:
metadata:
labels:
app: web-api
spec:
containers:
- name: api
image: registry.example.com/web-api:1.4.0
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: 8080Applying this manifest triggers a continuous reconciliation loop. Controllers continuously compare the desired state from configuration against the Observed State inside the cluster:
- The team specifies image
web-api:1.4.0and targetreplicas: 3in theDeployment. TheDeploymentmanages aReplicaSet, and theReplicaSetowns keeping the exact count of active Pods. - When
worker-03fails, the controller observes a drift: three replicas are desired, but only two active Pods remain.ReplicaSetimmediately creates a third Pod object. - The scheduler (
kube-scheduler) looks for a healthy node with spare CPU and RAM (such asworker-02). On the chosen node,kubeletinstructs the runtime (containerd) to pull the image and start the container. - While the process initializes,
kubeletexecutesreadinessProbeagainst port8080at/healthz. Once the app responds with200 OK, the Pod becomesReady, andServicebegins routing user requests to it.
A key property of the reconciliation loop is idempotence on every pass. Once three active Pods exist again, the next loop sees the target satisfied and creates no fourth copy. To scale the service, the team only needs to change the single replicas value in the declarative manifest.
3. Existing and ready replicas in kubectl output
To diagnose cluster incidents confidently, distinguish three state counters. Desired indicates how many copies are declared in the Deployment spec. Existing reflects how many active Pod objects the controller already tracks in the cluster. Ready shows how many of those Pods pass readinessProbe and actually serve client traffic through the Service.
A new Pod counts as Existing as soon as its API object is created, even while its image downloads, the server boots, or database pools warm up. Because of this, the ready count temporarily lags behind the existing count.
| Cluster situation | Desired | Existing | Ready | New Pods to create | kubectl get deploy output |
|---|---|---|---|---|---|
| API is healthy | 3 | 3 | 3 | 0 | READY 3/3 |
| Node lost, one Pod uncounted | 3 | 2 | 2 | 1 | READY 2/3 |
| Replacement created, container starting | 3 | 3 | 2 | 0 | READY 2/3 |
| Target raised from three to four | 4 | 3 | 3 | 1 | READY 3/4 |
See how the third situation (replacement created, not yet ready) looks in an operator's console when inspecting both the Deployment and the Pod list:
$ kubectl get deploy web-api
NAME READY UP-TO-DATE AVAILABLE AGE
web-api 2/3 3 2 12m
$ kubectl get pods -l app=web-api -o wide
NAME READY STATUS RESTARTS AGE IP NODE
web-api-7f9b8c6d4f-a1b2c 1/1 Running 0 12m 10.244.1.8 worker-01
web-api-7f9b8c6d4f-d3e4f 1/1 Running 0 12m 10.244.2.5 worker-02
web-api-7f9b8c6d4f-g5h6j 0/1 Running 0 18s 10.244.2.9 worker-02Notice two critical details in this output:
- In
kubectl get deploy,READYshows2/3, whileUP-TO-DATEalready reads3. This tells us the controller has created all three up-to-date Pods (Existing = 3), yet only two are serving traffic (AVAILABLE = 2). - In
kubectl get pods, the third Pod (g5h6j) is already scheduled ontoworker-02with statusRunning, yetREADYdisplays0/1—the process inside has not yet returned success on/healthz.
Also distinguish two levels of recovery. If the application process crashes, kubelet restarts the container in the same Pod on the same node (RESTARTS increments, while the Pod name and IP stay the same). If server worker-03 fails completely, ReplicaSet creates a brand-new Pod with a new name and IP address on a healthy node.
💡 Where to start diagnosing. Identical
READY 2/3output on aDeploymentcan hide different causes. WithExisting = 2andDesired = 3, inspect replacement creation events and available node capacity. WithExisting = 3andReady = 2, check the third Pod's container state, logs, andreadinessProbeconfiguration.
4. Practice. Modeling one reconciliation step
To solidify the math behind the reconciliation loop, model a single decision step of a ReplicaSet controller for an unchanged release. Suppose worker-03 powers off, leaving only two active Pods out of three desired. Save the following script as replica_model.py:
desired = 3
existing = 2
ready = 2
to_create = max(0, desired - existing)
print("desired:", desired)
print("existing:", existing)
print("ready:", ready)
print("to_create:", to_create)The first three lines set the input state counters. Subtracting desired - existing measures the active Pod deficit. Calling max(0, …) keeps the output from going negative when no new Pods need to be created. The model isolates the deficit-calculation step alone; node scheduling, scaling down excess copies, and readiness checks run in separate steps.
Run the script inside the directory where you saved it (use python3 instead of python if your interpreter uses that name):
python replica_model.pydesired: 3
existing: 2
ready: 2
to_create: 1Now test the model against two table scenarios and map them back to kubectl output:
- Change
existingto3while keepingready = 2(matching the third Pod in0/1 Runningfrom the previous section). Predictto_createfirst, then run the script. - Enter manual scaling values:
desired = 4,existing = 3,ready = 3, and recalculate how many objects will be created.
Practice answers
- With
desired = 3,existing = 3, andready = 2, the model outputsto_create: 0. The new Pod has already been created and counted (UP-TO-DATE 3), so no fourth Pod is needed. Until it passesreadinessProbe, the two ready Pods serve traffic via theService. - Raising the target to four (
desired = 4,existing = 3,ready = 3) yieldsto_create: 1. The controller creates a fourth Pod, though actually running it requires free capacity on a worker node.
5. Scaling, releases, and ownership boundaries
As traffic to the API grows, you can raise the replica count manually via a scale command or automatically with a HorizontalPodAutoscaler (HPA) driven by CPU, memory, or custom metrics. However, every new Pod consumes compute resources. If current nodes lack enough free memory or CPU, the newly created object stays in Pending:
$ kubectl scale deploy web-api --replicas=4
deployment.apps/web-api scaled
$ kubectl get pods -l app=web-api -o wide
NAME READY STATUS RESTARTS AGE IP NODE
web-api-7f9b8c6d4f-a1b2c 1/1 Running 0 15m 10.244.1.8 worker-01
web-api-7f9b8c6d4f-d3e4f 1/1 Running 0 15m 10.244.2.5 worker-02
web-api-7f9b8c6d4f-g5h6j 1/1 Running 0 3m 10.244.2.9 worker-02
web-api-7f9b8c6d4f-k8m9n 0/1 Pending 0 9s <none> <none>Notice <none> under NODE for the fourth Pod—the scheduler could not find a suitable host. Expanding the number of machines in the cluster is handled separately by node autoscaling tools (such as Cluster Autoscaler or Karpenter in cloud environments) or by an administrator adding servers.
When rolling out a new image version, Deployment replaces old Pods with new ones in batches (RollingUpdate). If the new image contains a business-logic bug or breaks database schema compatibility, automatic container restarts will not fix the defect—the service will crash repeatedly with the same code. Orchestration therefore never replaces engineering release verification.
| What Kubernetes handles | What the application or platform team owns |
|---|---|
Picking a node for a new Pod and enforcing Desired | Cluster capacity headroom and spreading replicas across failure domains |
| Restarting a crashed process or creating a replacement Pod | Defining accurate readinessProbe checks and fixing root causes in code |
Routing via Service and staged RollingUpdate | Validating releases under load, API/DB schema compatibility, and rollback decisions |
| Attaching a persistent volume to the scheduled Pod | Regular database backups and verified restore drills |
| Pulling an image and starting containers on the node | Building, testing, scanning images, pushing to registries, and managing credentials |
⚠️ Three replicas on one physical node share a single point of failure. Writing
replicas: 3is not enough to survive a server outage—verify that Pods spread across separate nodes, remaining machines have spare capacity, and two copies can handle full traffic.
Tool choice follows the scale of the problem. For local API and database development on a laptop, Docker Compose is simpler and faster. Kubernetes pays off when services run across a pool of nodes, deploy frequently without dropping traffic, and need automated recovery toward a target state after hardware faults—provided the team is ready to operate the cluster, networking, security policies, and upgrades.
6. Check your understanding
- Output from
kubectl get deploy web-apishowsREADY 2/3andUP-TO-DATE 3. What value will theto_createmodel produce, and where would you start troubleshooting? - After a node failure,
ReplicaSetcreates a replacement Pod object, yet client traffic has not fully recovered. What steps must that new Pod pass before receiving its first request throughService? - A faulty release
web-api:1.5.0wrote invalid rows into PostgreSQL. Is rolling theDeploymentback to1.4.0sufficient?
Answer discussion
to_create: 0. BecauseUP-TO-DATEis3, all three Pod objects already exist (Existing = 3). Checkkubectl get podsand inspect the container state andreadinessProbeof the third Pod showingREADY 0/1.- The scheduler must assign the Pod to a node with available resources (leaving
Pending),kubeletmust pull the image and start the container, and the app must passreadinessProbe. Only after transitioning toReady 1/1does the controller updateServiceendpoints. - No. Rolling back the
Deploymentrestores only the previous application code and image (1.4.0); it does not undo database changes. Recovering data requires a separate plan: restoring from a backup or running a compensating migration and verifying expected records.
You are ready to move on when you can look at kubectl get deploy and kubectl get pods output and immediately distinguish a missing Pod object (Existing < Desired), a scheduling bottleneck (Pending), and an unready container (0/1 Running). The next lesson covers OCI images, tags, digests, and the role of registries when starting containers in a cluster.
Sources
- Orchestration concepts and the Compose model. Kubernetes overview · Docker Compose application model
- Replica management, Deployment, and readiness. Deployment · ReplicaSet · Pod lifecycle
- Networking and scaling. Service · Horizontal Pod Autoscaler