Getting Started with GitOps Using Argo CD (or Flux)

Getting Started with GitOps Using Argo CD (or Flux)

Introduction.

In the rapidly evolving world of software delivery, teams are under constant pressure to ship features faster while maintaining reliability, security, and consistency across environments.
The shift from monolithic applications to microservices, and from static infrastructure to dynamic Kubernetes clusters, has made traditional deployment pipelines increasingly difficult to manage.
Manual deployments, brittle scripts, and snowflake environments introduce risk, inconsistency, and uncertainty into every release.

To overcome these challenges, the DevOps community has embraced a new paradigm known as GitOps.
At its core, GitOps extends the principles of DevOps by making Git the single source of truth for both application and infrastructure configurations.
This means that every desired state from a deployment manifest to a Helm release is stored, versioned, and reviewed in Git. Once merged, automation tools like Argo CD or Flux ensure that the state described in Git is reflected precisely in your running Kubernetes clusters.

In traditional CI/CD pipelines, the “CD” (continuous delivery) process often relies on scripts, manual approvals, and ad-hoc automation. With GitOps, however, the cluster itself becomes self-managing.
Instead of pushing changes into the cluster, you declare them in Git, and your GitOps controller continuously reconciles the live environment with what’s in the repository.
If something drifts from the desired state whether due to a manual change or a failed update the system automatically heals itself by reapplying what’s defined in Git.

This declarative model introduces a number of powerful benefits.
It provides version control for infrastructure, ensuring that every deployment, rollback, or environment change is traceable and auditable. It fosters collaboration, since changes follow the same pull request workflow developers already use for code. It enforces consistency, allowing identical configurations to be deployed across multiple clusters or environments. And perhaps most importantly, it reduces human error, since no one needs to manually apply manifests or run fragile scripts during a release.

Tools like Argo CD and Flux have become the leading implementations of GitOps for Kubernetes.
Both are open source, cloud-native, and CNCF projects that make it easy to manage complex systems declaratively. Argo CD provides a powerful UI, detailed visualization of sync status, and fine-grained control over application lifecycles. Flux, on the other hand, emphasizes simplicity and composability, integrating deeply with Git and Helm while offering automation primitives for a variety of GitOps workflows.
Regardless of which you choose, the core philosophy remains the same your Git repository defines reality, and your cluster obeys it.

GitOps is not just about automation it’s about trust. It allows teams to trust that their production environment always matches the intended configuration. It allows developers to trust that changes have been reviewed, tested, and versioned. And it allows organizations to trust that their delivery process is repeatable, secure, and observable. In an era where reliability and velocity often seem at odds, GitOps brings them together through the simplicity of declarative infrastructure and the power of Git workflows.

In this post, we’ll take a hands-on look at how to get started with GitOps using Argo CD (or Flux).
You’ll learn how to install the tool, connect it to your Git repository, define your first application, and experience the magic of automated synchronization. By the end, you’ll have a complete understanding of how GitOps works not as a buzzword, but as a practical, powerful way to manage modern software delivery.
Let’s dive in and see how GitOps can transform your deployment process from a fragile manual routine into a seamless, automated, and auditable system.

What You’ll Learn

  • What GitOps is (and why it matters)
  • Setting up a GitOps workflow with Argo CD (or Flux)
  • Deploying a sample app using Git as the source of truth
  • Common patterns and best practices

Prerequisites

Before we start, make sure you have:

  • A running Kubernetes cluster (e.g., Minikube, Kind, EKS, GKE, AKS)
  • kubectl configured for your cluster
  • A GitHub (or GitLab) repository
  • (Optional) helm if you’re using charts

Step 1: Install Argo CD (or Flux)

Option 1: Argo CD

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Access the Argo CD UI:

kubectl port-forward svc/argocd-server -n argocd 8080:443

Log in using the admin password:

kubectl -n argocd get secret argocd-initial-admin-secret \
  -o jsonpath="{.data.password}" | base64 -d; echo

Option 2: Flux

brew install fluxcd/tap/flux
flux install

Then bootstrap your repo:

flux bootstrap github \
  --owner=<your-github-username> \
  --repository=<your-repo> \
  --branch=main \
  --path=clusters/my-cluster

Step 2: Create Your GitOps Repository Structure

A typical GitOps repo might look like this:

gitops-demo/
├── apps/
│   └── myapp/
│       ├── deployment.yaml
│       └── service.yaml
└── clusters/
    └── production/
        └── app.yaml

The apps/ folder contains your manifests or Helm charts,
and the clusters/ folder contains Argo CD or Flux configuration pointing to those apps.

Step 3: Define the Application in Argo CD

Create a file named app.yaml:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/<your-username>/gitops-demo.git
    targetRevision: main
    path: apps/myapp
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Apply it:

kubectl apply -f clusters/production/app.yaml

Argo CD will automatically deploy and keep your app in sync with Git.

Step 4: Make a Change and Watch GitOps in Action

Try editing your deployment.yaml (e.g., change the image tag):

containers:
- name: myapp
  image: nginx:1.27

Commit and push:

git add .
git commit -m "Update image version"
git push

Argo CD (or Flux) will detect the change and apply it automatically no manual kubectl apply needed!

Best Practices

  • Use separate repos for app code and environment configs
  • Implement branch protections and PR reviews
  • Enable auto-sync + self-healing cautiously (especially in prod)
  • Use Helm or Kustomize for flexibility
  • Integrate notifications (Slack, Teams, etc.) for deployments

Conclusion

GitOps with Argo CD (or Flux) turns your Git repository into your deployment engine. Once configured, you’ll spend less time fighting CI/CD pipelines and more time shipping reliable changes confidently.

Whether you’re deploying a small web app or managing complex microservices, GitOps offers visibility, reproducibility, and peace of mind.

Tags: No tags

Comments are closed.