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 taskSingle host (Docker Compose)Cluster (Kubernetes)
Physical or virtual server failureSingle point of failure (SPOF): every container on the node goes downA controller recreates missing Pods on healthy cluster nodes
Selecting a machine for a copyAn engineer manually picks a host with free RAM/CPUThe scheduler (kube-scheduler) automatically finds a node matching resource requests
Networking and load balancingTied to host ports and a local bridge; external load balancers require separate setupA stable internal Service address and DNS name distribute traffic across nodes
Readiness verificationA container gets requests as soon as PID 1 starts, even before caches warm upService routes traffic only to Pods passing readinessProbe
Zero-downtime updatesStopping and recreating a container drops active connections without custom scriptsDeployment 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.

ConceptRole in this lesson's architecture
ClusterA group of worker machines paired with the Control Plane management components
NodeA physical or virtual machine in the cluster that runs workloads
PodThe smallest placement unit. Usually holds one main application container (occasionally helper containers)
ReplicaSetA controller that watches active Pods and maintains their requested count
DeploymentA declarative object managing application version, replica count, and rollout strategy
ServiceA 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.

Reconciliation loop: Deployment target of three replicas, observing two active Pods on nodes, creating a replacement, and joining the Service
Reconciliation loop: Deployment target of three replicas, observing two active Pods on nodes, creating a replacement, and joining the Service

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:

yaml
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: 8080

Applying this manifest triggers a continuous reconciliation loop. Controllers continuously compare the desired state from configuration against the Observed State inside the cluster:

  1. The team specifies image web-api:1.4.0 and target replicas: 3 in the Deployment. The Deployment manages a ReplicaSet, and the ReplicaSet owns keeping the exact count of active Pods.
  2. When worker-03 fails, the controller observes a drift: three replicas are desired, but only two active Pods remain. ReplicaSet immediately creates a third Pod object.
  3. The scheduler (kube-scheduler) looks for a healthy node with spare CPU and RAM (such as worker-02). On the chosen node, kubelet instructs the runtime (containerd) to pull the image and start the container.
  4. While the process initializes, kubelet executes readinessProbe against port 8080 at /healthz. Once the app responds with 200 OK, the Pod becomes Ready, and Service begins 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.

Three cluster snapshots: all three Pods ready, one Pod lost on a node, and replacement created and starting
Three cluster snapshots: all three Pods ready, one Pod lost on a node, and replacement created and starting

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 situationDesiredExistingReadyNew Pods to createkubectl get deploy output
API is healthy3330READY 3/3
Node lost, one Pod uncounted3221READY 2/3
Replacement created, container starting3320READY 2/3
Target raised from three to four4331READY 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:

Linux / Bash
$ 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-02

Notice two critical details in this output:

  • In kubectl get deploy, READY shows 2/3, while UP-TO-DATE already reads 3. 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 onto worker-02 with status Running, yet READY displays 0/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/3 output on a Deployment can hide different causes. With Existing = 2 and Desired = 3, inspect replacement creation events and available node capacity. With Existing = 3 and Ready = 2, check the third Pod's container state, logs, and readinessProbe configuration.

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:

python
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):

Linux / Bash
python replica_model.py
text
desired: 3
existing: 2
ready: 2
to_create: 1

Now test the model against two table scenarios and map them back to kubectl output:

  1. Change existing to 3 while keeping ready = 2 (matching the third Pod in 0/1 Running from the previous section). Predict to_create first, then run the script.
  2. Enter manual scaling values: desired = 4, existing = 3, ready = 3, and recalculate how many objects will be created.
Practice answers
  1. With desired = 3, existing = 3, and ready = 2, the model outputs to_create: 0. The new Pod has already been created and counted (UP-TO-DATE 3), so no fourth Pod is needed. Until it passes readinessProbe, the two ready Pods serve traffic via the Service.
  2. Raising the target to four (desired = 4, existing = 3, ready = 3) yields to_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:

Linux / Bash
$ 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 handlesWhat the application or platform team owns
Picking a node for a new Pod and enforcing DesiredCluster capacity headroom and spreading replicas across failure domains
Restarting a crashed process or creating a replacement PodDefining accurate readinessProbe checks and fixing root causes in code
Routing via Service and staged RollingUpdateValidating releases under load, API/DB schema compatibility, and rollback decisions
Attaching a persistent volume to the scheduled PodRegular database backups and verified restore drills
Pulling an image and starting containers on the nodeBuilding, testing, scanning images, pushing to registries, and managing credentials

⚠️ Three replicas on one physical node share a single point of failure. Writing replicas: 3 is 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

  1. Output from kubectl get deploy web-api shows READY 2/3 and UP-TO-DATE 3. What value will the to_create model produce, and where would you start troubleshooting?
  2. After a node failure, ReplicaSet creates a replacement Pod object, yet client traffic has not fully recovered. What steps must that new Pod pass before receiving its first request through Service?
  3. A faulty release web-api:1.5.0 wrote invalid rows into PostgreSQL. Is rolling the Deployment back to 1.4.0 sufficient?
Answer discussion
  1. to_create: 0. Because UP-TO-DATE is 3, all three Pod objects already exist (Existing = 3). Check kubectl get pods and inspect the container state and readinessProbe of the third Pod showing READY 0/1.
  2. The scheduler must assign the Pod to a node with available resources (leaving Pending), kubelet must pull the image and start the container, and the app must pass readinessProbe. Only after transitioning to Ready 1/1 does the controller update Service endpoints.
  3. No. Rolling back the Deployment restores 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