6.8 Kubernetes Declarative State Model
Kubernetes uses a declarative state model to define and manage cluster infrastructure through declarative manifests and automated reconciliation.
Kubernetes Declarative State Model is the overarching architectural philosophy in which cluster behavior is driven not by a sequence of imperative commands but by continuously comparing a declared desired state against observed actual state and taking corrective action to close any gap, a model that underlies manifests, controllers, and the entire reconciliation-based design of the system rather than being confined to any single component.
Declarative Versus Imperative Paradigms
Imperative: A Sequence of Steps
An imperative approach to managing infrastructure specifies a sequence of operations to perform, such as "start three containers, then configure a load balancer, then update DNS," where correctness depends on the operations being executed in the right order, against the right starting state, and the model does not naturally describe how to recover if something is later manually changed outside that sequence.
Declarative: A Description of an End State
A declarative approach instead specifies only the desired end state, such as "three replicas of this container should be running," leaving the system responsible for determining and executing whatever operations are necessary to reach and maintain that state, regardless of the starting point or of subsequent external interference.
Why Kubernetes Chose Declarative
Declarative state management scales better to distributed, continuously changing environments where nodes fail, pods crash, and manual interventions occur unpredictably, since a declarative system's response to any deviation, whatever its cause, is uniform: reconcile back toward the declared state, rather than requiring bespoke recovery logic for every possible failure scenario.
Level-Triggered Versus Edge-Triggered Reconciliation
Level-Triggered Design
Kubernetes controllers are designed to be level-triggered rather than edge-triggered, meaning they react to the current difference between desired and actual state rather than to the specific event that caused that difference; a controller that missed a particular change event due to a restart or network blip will still correctly reconcile once it resumes, simply by comparing current state again, without needing to have observed every individual historical event.
Resilience to Missed Events
This level-triggered property is what makes the system resilient to component restarts, network partitions, and processing delays: because reconciliation is driven by re-evaluating the gap between spec and actual state rather than replaying a precise history of events, a controller can always recover correctness simply by looking at current state again.
Idempotency as a Core Property
Reapplication Without Side Effects
A properly designed declarative system treats repeated application of the same desired state as safe and side-effect-free: applying an unchanged manifest a second time should produce no meaningful change, since the system was already converged toward that state, a property that would not hold for an imperative sequence of commands, which might duplicate effects if rerun.
Enabling Safe Automation
Idempotency is what allows declarative configuration to be embedded safely into automated pipelines that might retry operations after a failure or reapply configuration on every deployment cycle, without operators needing to reason carefully about whether a retry might cause unintended duplicate effects.
Convergence and Eventual Consistency
The System Is Always Converging, Rarely Converged
At any given moment, a busy cluster typically has some number of objects whose actual state has not yet caught up to their most recently declared desired state, meaning the system should be understood as continuously converging rather than existing in a permanently converged state, with brief periods of full convergence being the exception rather than the rule during active change.
Convergence Does Not Guarantee a Fixed Timeline
The declarative model makes no strict promise about how quickly convergence will occur, only that the system will continue working toward it; this is a deliberate tradeoff, prioritizing eventual correctness and resilience over strict timing guarantees that would be difficult to uphold reliably across a distributed system experiencing partial failures.
Manifests as the Entry Point Into the Model
Manifests Express, Controllers Fulfill
Manifests are the practical mechanism by which desired state enters this declarative model in the first place: a manifest declares intent, and every subsequent controller action, from a Deployment creating ReplicaSets to a kubelet starting containers, exists entirely to progressively fulfill that declared intent, layer by layer, down to the level of an actual running process.
The Model Extends Beyond a Single Manifest
While an individual manifest declares state for a single object, the declarative model as a whole extends across the interlocking chain of controllers that each declare further desired state for the objects they create, meaning a single top-level manifest's influence propagates through many layers of declarative reconciliation before it manifests as running infrastructure.