Desired state and reconciliation
Desired state versus observed state
Desired state is what you have asked Kubernetes to maintain. Observed state is what its components currently report. A controller is a program that repeatedly examines relevant information and acts to reduce differences between the requested and observed state. This process is called reconciliation. For three desired copies and two remaining copies, a suitable controller can request a replacement.
A repeating feedback loop
A declarative request says what result should be maintained, rather than spelling out every action to perform. The controller observes state, compares it with the request, and takes appropriate action or waits for another component. It then observes again. Several controllers can cooperate: a Deployment manages ReplicaSets, and a ReplicaSet maintains its set of Pods. Other components place and start the Pods. These roles will be explored in the architecture chapter.
Read a recovery timeline
The following numbers are a synthetic teaching fixture, not kubectl output. Assume a functional controller, enough eventual capacity, an available image and no simultaneous scaling change.
- Step 0: desired 3, existing 3, ready 3.
- Step 1: desired 3, existing 2, ready 2. A Pod has disappeared.
- Step 2: desired 3, existing 3, ready 2. A replacement exists but is not ready.
- Step 3: desired 3, existing 3, ready 3. The replacement has become ready.
Ready means Kubernetes considers a Pod ready based on its readiness conditions. It is useful evidence, not proof that every application feature is working. A real cluster may report delayed observations, additional intermediate states or failures.
Example: a blocked replacement
Suppose a workload wants four copies. Three are ready, and the fourth exists but cannot be placed on a node because no node has sufficient requested resources available. Creating another Pod indiscriminately does not create more physical capacity. Investigate why the existing replacement is blocked. Changing capacity, workload requirements or placement constraints may be appropriate after diagnosis.
Common mistakes
Do not treat an accepted configuration request as proof of a successful deployment. Do not assume the desired number is the number already running, or the number ready. Do not assume reconciliation has a fixed completion time. If the controller or other required infrastructure is unavailable, recovery may stall.
Practice: state prediction
Use the synthetic timeline in lab-fixtures/synthetic-api/replica-loss.json from the accompanying package. Explain why step 2 is not full recovery, then predict the ready count if the replacement remains unable to start and the other two remain ready. Next: When to use Kubernetes.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Desired state and reconciliation — knowledge check
Apply the concepts from this lesson to short offline scenarios.
Desired is 3, existing is 2, ready is 2. What is the immediate gap in existing copies?
Desired is 3, existing is 3, ready is 2. What can you conclude?
What best describes reconciliation?
A replacement cannot be placed because available resources are insufficient. What should you do first?
A controller is unavailable. What is a reasonable expectation?