Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 243 of 8024. Kubernetes Architecture and Core ObjectsFree lesson

Maintaining Desired State Through Reconciliation

Trace the end-to-end reconciliation process where components collaborate to resolve discrepancies between the current cluster state and the intended operational configuration.

In this lesson, you will learn how the Kubernetes control plane constantly monitors and fixes your cluster to match your intended configuration.

The Reconciliation Loop: Kubernetes’ "Self-Correction" Engine

At its heart, Kubernetes operates on a reconciliation loop. This is the process where the system continuously observes the current state of your infrastructure and compares it against the "desired state" you defined in your manifest files. If there is a discrepancy, the system takes action to align the two.

Think of it like a smart thermostat. You set the temperature to 72°F (the desired state). The thermostat constantly checks the room temperature (the current state). If the room is 68°F, the thermostat triggers the heater until the current state matches your target.

The Collaboration Flow

The process involves a constant, non-stop dance between components:

  1. Define: You submit a YAML manifest to the API Server (e.g., "I want 3 replicas of my web server").
  2. Store: The API Server saves this definition as the source of truth in etcd.
  3. Observe: The Controller Manager watches the API Server. It notices that currently, 0 pods are running.
  4. Act: The Controller Manager triggers an action to create those 3 pods.
  5. Schedule: The Scheduler identifies which worker nodes have the capacity to host these pods.
  6. Execute: The Kubelet on the assigned nodes receives the instruction and starts the containers.

If a container crashes later, the Kubelet reports the failure to the API Server. The Controller Manager sees the discrepancy (Current: 2 pods, Desired: 3 pods) and immediately instructs the cluster to spin up a new replacement pod to close the gap.

# Desired State: 3 Replicas
apiVersion: apps/v1
kind: ReplicaSet
spec:
  replicas: 3
  template: # Pod definition
    ...

This loop never sleeps. Whether it’s a node failure, a manual delete command, or an unexpected crash, the reconciliation process ensures the cluster fights to maintain the configuration you declared. You don't have to tell the system "how" to fix it; you only define "what" you want, and the control plane manages the rest.

Key Takeaway: Reconciliation is an infinite loop of observing the current state, comparing it to the desired state, and executing actions to eliminate the difference.