Logo Codebaker
IT

GitOps with Argo CD: declarative deploys, drift detection and rollback on Kubernetes

by Luca Vitali ·

What GitOps is

GitOps is a way of managing infrastructure in which the desired state of the system is described declaratively inside a Git repository, and an automated component keeps the real cluster in line with that description. Git becomes the single source of truth: every change is a commit, with an author, a review and a history. You no longer run manual commands against the cluster: you change the repository and the system adapts.

Why Argo CD

Argo CD is a controller that runs inside Kubernetes and watches one or more repositories. When the repo changes, it compares the manifests with what is actually running and applies the differences. It provides a dashboard that shows, for each application, whether it is aligned (Synced) or whether something was changed outside Git (OutOfSync). This makes the state of dozens of services visible in seconds.

Drift detection and rollback

Drift is the gap between what is written in Git and what is really running: an emergency kubectl change, an operator altering a resource, a regression. Argo CD highlights drift and, depending on the configuration, can flag it or fix it by itself (self-heal). Rollback is just as simple: since every state is a commit, going back means pointing the application to a previous revision, with nothing rebuilt by hand.

How to adopt it safely

It is best to proceed in stages. At first you keep Argo CD in observation mode with manual sync: you see the drift but apply it by hand, to build confidence. Then you enable automated sync on non-critical namespaces (development and staging) and finally, once the team trusts the flow, in production too, with the proper safeguards: maintenance windows, approvals and security policies on the repositories.

When you do not need it

GitOps shines when you manage multiple environments and services on Kubernetes. For a single service on a VM, or for throwaway experiments, the overhead may not be worth it. The rule of thumb is simple: if you are already writing declarative manifests and want traceability and repeatability, GitOps is the natural next step.

FAQ

Does GitOps replace the CI/CD pipeline?

No, it complements it. CI builds and tests the images; GitOps (CD) brings the declared state into the cluster. Often the pipeline updates the deploy repository and Argo CD applies the rest.

What is the difference between Argo CD and Flux?

Both are mature CNCF GitOps tools. Argo CD offers a rich dashboard and an application model; Flux is more modular and composition-oriented. The choice depends on team preference and the existing ecosystem.

Does Argo CD need write access to the cluster?

Yes, Argo CD applies resources and therefore holds cluster permissions. They should be limited with RBAC to the minimum needed, and the source repositories must be protected, because they become the key to deployments.

Sources