AS
Ahmed Shams

Shams Systems · DevOps Engineer

Operational
Back to Blog & Docs
GitOpsKubernetesDevOps

GitOps in Practice: Declarative Kubernetes Delivery with ArgoCD

A complete guide to continuous deployment, automated drift reconciliation, and multi-environment GitOps using ArgoCD and Helm.

AS

Ahmed Shams

Feb 18, 20269 min read

GitOps is an operational framework that takes DevOps best practices used for application development — such as version control, collaboration, compliance, and CI/CD — and applies them to modern cloud infrastructure automation.

Note

In a true GitOps workflow, Git is the single source of truth for your entire cluster state. Direct manual changes via kubectl are strictly discouraged or automatically reverted.

The Four Principles of GitOps

  • Declarative Descriptions: The entire system is described declaratively in Git (Kubernetes YAML, Helm, Kustomize).
  • Versioned & Immutable: Desired state is stored in Git, offering complete audit logs and one-click rollback.
  • Pulled Automatically: Software agents (like ArgoCD) continuously pull desired state rather than CI pushing blindly.
  • Continuously Reconciled: Software agents continuously observe live cluster state and reconcile differences automatically.

Installing ArgoCD on Kubernetes

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

# Access the ArgoCD Web UI locally
kubectl port-forward svc/argocd-server -n argocd 8080:443

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

Defining an ArgoCD Application Manifest

Rather than creating apps via the UI, GitOps teams define Application Custom Resources (CRDs) stored directly in git:

yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: petclinic-production
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  source:
    repoURL: 'https://github.com/my-org/gitops-manifests.git'
    targetRevision: HEAD
    path: environments/production/petclinic
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: production
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true

Tip

Enabling selfHeal ensures that if someone manually alters a deployment in production, ArgoCD detects the configuration drift and reverts it to the Git-defined spec within seconds.

Multi-Environment Directory Strategy

Organizing your GitOps repository with Kustomize overlays allows sharing base manifests while overriding replicas, resource limits, and secrets per environment (dev, staging, prod).

“

With GitOps, recovering from cluster disasters transforms from hours of emergency fire-fighting into a single git revert and automated ArgoCD sync.

— DevOps Best Practices