GitOps Terminology (20%)
Notes on gitops terminology.
Topics
- Continuous
- Declarative Description
- Desired State
- State Drift
- State Reconciliation
- GitOps Managed Software System
- State Store
- Feedback Loop
- Rollback
Continuous
- Continuously monitoring a system and comparing a live state to a desired state ensures that the environment maintains the desired state
- OpenGitOps: “continuous” means reconciliation keeps happening, not that it must be instantaneous (e.g. polling every few minutes still counts)
Declarative Description
- Declarative simply states what you want the system to look like. You declare the desired state, and GitOps gets the environment to that desired state.
- Why it matters?
- Easy to understand the systems’ purpose
- version controlled, providing a complete history of the environment
- The environment can adapt to changes without manual intervention
- OpenGitOps: a configuration that describes the desired operating state of a system without specifying procedures for how that state will be achieved. Separates configuration (desired state) from implementation (commands, API calls, scripts).
Desired State
- The “master” plan for the environment
- What does the environment look like in a “perfect” state
- OpenGitOps: the aggregate of all configuration data that is sufficient to recreate the system so that instances are behaviourally indistinguishable
- Usually excludes persistent application data (database contents, etc.). Desired state is config, not data.
State Drift
- State drift occurs when the live state no longer matches the desired state/what is stored in the SCM.
- Common causes: manual
kubectl edit/scale, other controllers or mutating webhooks, failed partial applies, someone changing resources in the cloud console - Argo CD shows drift as
OutOfSync. WithselfHealit reverts it automatically.
State Reconciliation
- State reconciliation is the act of bringing the environment into the desired state, and mitigating any state drift.
- State drift can lead to unexpected errors and instability. It is an “unexpected” state and can make troubleshooting more difficult.
- The GitOps operator will continuously loop through the following states:
- Observe
- Diff
- Act
- Unlike traditional CD (triggered by a pipeline event), GitOps reconciliation is triggered whenever there is a divergence between desired and actual state
GitOps Managed Software System
- Any system that is controlled and updated via GitOps principles
- OpenGitOps says it includes:
- One or more runtime environments made up of resources under management
- The management agents within each runtime
- Policies for controlling access and management of repositories, deployments, and runtimes
State Store
- Where configuration for the environment is stored
- A single source of truth
- Examples:
Git(hosted on GitHub, GitLab, Bitbucket, …), OCI registries, S3 buckets - OpenGitOps: a system for storing immutable versions of desired state declarations. It should provide access control and auditing on changes to the desired state.
Feedback Loop
- A process where changes made in a Git repository are continuously monitored and reconciled with the actual state of the deployed environment. This ensures that any discrepancies are automatically corrected, enhancing the reliability and consistency of deployments.
- Based on control theory: GitOps is a closed-loop system. The actual output (live state) is fed back and compared to the desired input, and corrections are made. An open loop (fire-and-forget
kubectl apply) never checks the result. - Also refers to feedback to humans: sync/health status, notifications, and commit status on the PR
Rollback
- Quickly undo changes made to the environment
- In GitOps, roll back by reverting the commit in Git (
git revert). The agent then reconciles the cluster to the previous version. kubectl rollout undoorargocd app rollbackchanges the cluster but not Git, so it creates drift. The agent will re-apply the “bad” version from Git (Argo CD disables auto-sync for a rollback for this reason).- Prefer
git revertovergit reset+ force-push. Revert keeps history (Versioned and Immutable).
Self-check
1. An on-call engineer runs kubectl rollout undo during an incident, and 3 minutes later the bad version is back. Why?
Answer
Git still declares the bad version. The agent saw the drift and reconciled back to the desired state. Roll back by reverting the commit in Git.
2. Define state drift vs. state reconciliation.
Answer
Drift: the actual state has moved (or is moving) away from the desired state. Reconciliation: the process of making the actual state match the desired state again.
3. Does “continuous” reconciliation require instant, event-driven updates?
Answer
No. It means reconciliation keeps happening over time. Periodic polling is fine.