DEVOPS / A CONCEPT NOTE
Declarative vs Imperative
describing vs commanding
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Declarative states WHAT the infrastructure should look like (e.g. Kubernetes, Terraform), while Imperative states HOW to build it using a series of steps (e.g. bash scripts, CLI commands).
02 / FOLLOW THE MECHANISM
How reconciliation flows
Declarative spec
user specifies: 'I want 3 replicas' in a config file.
Reconciliation Engine
system constantly checks the live state and corrects deviations automatically.
Imperative script
runs command: 'launch server' then 'install packages'.
Errors handle
imperative fails if a step breaks halfway; declarative recovers automatically.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
declaratively apply a configuration state
kubectl apply -f deployment.yamlimperatively command pod creation
kubectl create deployment my-app --replicas=305 / CHECK YOURSELF
Could you explain Declarative vs Imperative to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Delivery & operationsIdempotencywhy running twice must be safe