Feedback

Chat Icon

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

What Argo CD Actually Does: GitOps, Reconciliation, and Why Immutable Wins
15%

Declare the Outcome, Not the Steps: The Irrigation Analogy

Imagine you want to set up a smart home garden irrigation system. In an action-oriented, instruction-based approach, you would manually control the watering process by giving specific commands about how much water (in cm3 or fluid ounces) to give to each plant, based on its size and type:

  • Water small plants with 0.1 cm3 of water every 2 days.
  • Water medium plants with 0.3 cm3 of water every 2 days.
  • Water trees with 1 cm3 of water every 2 days.
  • ...

This method works, but it has limitations and the smart home garden irrigation system is not really smart. The smartness relies on you, the user. Think of it this way: what happens if it rains the same day you water the garden? You'd still follow the same rigid instructions, even if they're no longer appropriate, and your garden may get flooded as it receives water from both the rain and the irrigation system.

In this approach the system is always responsible for making sure the process made by the user is followed exactly, and the system doesn't adapt to changes on its own. This is a procedural approach, also known as imperative programming.

In a smarter way, instead of writing steps, you simply describe the outcome you want:

  • At any given time, the soil moisture level for each plant should be between 60% and 80%.

The system figures out how to achieve that. It can adjust based on weather conditions. If it rains a lot, the system won't water the plants. If it's hot and dry, the system waters the plants more frequently. You're not concerned with the specific steps; you're focused on the final result, and the system adapts to ensure that the goal is consistently met.

This is the declarative approach.

To better understand this concept, let's take a simple example: installing Nginx on a server.

In the imperative approach, you would write a script:

apt-get update
apt-get install -y nginx

If you run this script multiple times, it will always update the package list and run the apt-get install command, even if Nginx is already installed. The script doesn't know in advance the state of the system, so it always executes the same steps.

Now, let's see how this would look in a declarative approach. You have probably used Ansible or an automation tool like SaltStack. When you want to install a package, nginx in our case, you would write a task like this:

GitOps the Hard Way, with Argo CD

Build Real GitOps Pipelines From Empty Clusters to Automated Deploys

Enroll now to unlock all content and receive all future updates for free.