GitOps with ArgoCD in Production
A practical guide to implementing GitOps workflows with ArgoCD for multi-environment Kubernetes deployments.
GitOps has become the de facto standard for deploying applications to Kubernetes. In this guide, I'll walk through how we implemented ArgoCD for production workloads across multiple environments.
What is GitOps?
GitOps is a operational framework that uses Git as the single source of truth for infrastructure and application definitions. Changes are made via pull requests, and an automated agent (ArgoCD) reconciles the desired state with the actual cluster state.
Key Principle
If it's not in Git, it doesn't exist in production.
Setting Up ArgoCD
Install ArgoCD in your management cluster:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlConfigure the ArgoCD CLI:
argocd login argocd.example.com --grpc-web
argocd cluster add production-cluster --name productionApplication Structure
We organize our GitOps repository with the following structure:
apps/
├── base/
│ ├── deployment.yaml
│ ├── service.yaml
│ └── kustomization.yaml
├── overlays/
│ ├── staging/
│ └── production/
Multi-Environment Strategy
Each environment uses Kustomize overlays to manage differences:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app-production
namespace: argocd
spec:
project: production
source:
repoURL: https://github.com/org/gitops-repo
targetRevision: main
path: apps/overlays/production
destination:
server: https://production-cluster
namespace: my-app
syncPolicy:
automated:
prune: true
selfHeal: trueProduction Sync Policy
Enable automated sync only after thorough testing in staging. Start with manual sync for production environments.
Best Practices
- Use App of Apps pattern for managing multiple applications
- Implement sync waves for ordered deployments
- Set resource hooks for database migrations
- Configure RBAC with project-level isolation
- Enable notifications for sync status updates
Monitoring Sync Health
ArgoCD exposes Prometheus metrics out of the box. Key metrics to alert on:
argocd_app_sync_total— sync operation countargocd_app_health_status— application healthargocd_app_reconcile_count— reconciliation frequency
Conclusion
GitOps with ArgoCD transformed our deployment workflow from manual kubectl applies to fully automated, auditable, and reversible deployments. The key is starting simple with one application and gradually expanding the pattern across your organization.
Related Articles
Istio Service Mesh in Production
Lessons learned from running Istio service mesh across a multi-cluster Kubernetes platform.
Blue-Green Deployments on Kubernetes
Implement zero-downtime blue-green releases with Kubernetes Services, Ingress, and CI/CD automation.
GitLab CI to Kubernetes: End-to-End Deploy Pipeline
Design a complete CI/CD pipeline from GitLab merge request to Kubernetes production with security gates and GitOps handoff.