Declarative vs. Imperative Configuration

Understand the difference between declarative and imperative configurations when using GitOps.

GitOps principles specify that our description of the system must be declarative, but what does that look like? To better understand declarative configuration, let’s compare it with its alternative, imperative configuration.

Imperative configuration

To draw an analogy, think about the instructions provided with a piece of furniture that tells you how to assemble it. The instructions are like imperative configurations because they define a set of steps that are followed one after the other. With each step, commands described in the instructions are performed and, by the end of the instructions, there is (hopefully) a new piece of furniture assembled.

Those who work in technical roles are probably familiar with imperative style configurations, which often come in the form of scripts that specify a sequence of commands executed on the command line. The example below demonstrates this approach using a shell script to install Docker:

Get hands-on with 1200+ tech skills courses.