๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

GitOps Workflow: Managing Infrastructure with Git and ArgoCD

GitOps Workflow: Managing Infrastructure with Git and ArgoCD

GitOps is an operational framework that uses Git as the single source of truth for declarative infrastructure and application delivery. ArgoCD is the most popular GitOps tool for Kubernetes, automating deployment synchronization between your Git repository and live cluster.

What Is GitOps?

  • Git as single source of truth: All desired state is stored in Git
  • Declarative: You describe the desired state, not the steps to get there
  • Automated: Changes in Git automatically apply to infrastructure
  • Observable: Drift detection alerts when actual state differs from desired state

GitOps vs Traditional CI/CD

  • Traditional: CI builds โ†’ CD pushes to cluster (push-based)
  • GitOps: CI builds โ†’ commits to Git โ†’ ArgoCD pulls from Git โ†’ syncs cluster (pull-based)

Installing ArgoCD

# Create namespace
kubectl create namespace argocd

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

# Wait for pods
kubectl wait --for=condition=Ready pods --all -n argocd --timeout=300s

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

# Port forward to access UI
kubectl port-forward svc/argocd-server -n argocd 8080:443

# Install CLI
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd

Repository Structure

infrastructure-repo/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ web-app/
โ”‚   โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ”‚   โ””โ”€โ”€ ingress.yaml
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”‚   โ””โ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ database/
โ”‚       โ”œโ”€โ”€ statefulset.yaml
โ”‚       โ””โ”€โ”€ service.yaml
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ namespace.yaml
โ”‚   โ””โ”€โ”€ network-policy.yaml
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ development/
    โ”‚   โ””โ”€โ”€ kustomization.yaml
    โ”œโ”€โ”€ staging/
    โ”‚   โ””โ”€โ”€ kustomization.yaml
    โ””โ”€โ”€ production/
        โ””โ”€โ”€ kustomization.yaml

Creating an ArgoCD Application

# application.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: web-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/company/infrastructure
    targetRevision: main
    path: apps/web-app
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Sync Strategies

  • Manual sync: Review changes before applying (recommended for production)
  • Auto sync: Automatically apply changes when Git changes
  • Self-heal: Revert manual cluster changes to match Git state
  • Prune: Delete resources removed from Git

Deployment Workflow

  1. Developer creates a Pull Request with infrastructure changes
  2. Team reviews the PR (code review for infrastructure)
  3. PR is merged to main branch
  4. ArgoCD detects the change and syncs the cluster
  5. ArgoCD reports sync status (Healthy, Degraded, or OutOfSync)

Rollback

# ArgoCD CLI rollback
argocd app rollback web-app

# Or simply revert the Git commit
git revert HEAD
git push origin main
# ArgoCD automatically syncs to the reverted state

Best Practices

  1. Separate application code repositories from infrastructure repositories
  2. Use branch protection rules on the infrastructure repo
  3. Require PR reviews for all infrastructure changes
  4. Use Kustomize or Helm for environment-specific configurations
  5. Enable notifications for sync failures
  6. Implement RBAC for ArgoCD access control
  7. Use sealed secrets or external secret operators for sensitive data

GitOps with ArgoCD brings the same rigor and auditability to infrastructure management that we expect from application development. Every change is versioned, reviewed, and traceable โ€” making your operations more reliable and your team more confident.

Share this article:
Marco Rinaldi
About the Author

Marco Rinaldi

Web Development, Full-Stack Engineering, Application Architecture, Technical Documentation

Marco Rinaldi is a web and full-stack developer focused on building reliable, maintainable, and well-structured web applications.

He works across frontend and backend environments, combining modern web technologies with sound architectural principles. His experience includes application logic, API development, database...

Frontend Development Backend Development REST APIs Databases Web Architecture

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.