GitOps Best Practices and Production Lessons

What I Learned Running GitOps in Production

After 2 years running ArgoCD in production with 200+ applications across 12 clusters, here's what I learned the hard way.

The Incident That Taught Me About Secrets

3 AM. Slack alert: "Database password exposed in Git!"

Someone committed this:

# DO NOT DO THIS!
apiVersion: v1
kind: Secret
metadata:
  name: db-secret
stringData:
  password: "SuperSecret123!"  # ← Visible in Git history!

Even though we reverted immediately, the secret was in Git history forever. We had to:

  1. Rotate all database passwords

  2. Audit entire Git history

  3. Force-push to remove secret (risky)

  4. Implement secret scanning

Cost: 6 hours of downtime, $50k in lost revenue.

Let me show you how to handle secrets properly.

Secret Management

DON'T: Store Secrets in Git

DO: Use Sealed Secrets

Sealed Secrets encrypts secrets that can be safely committed to Git.

Install Sealed Secrets Controller

Install kubeseal CLI

Create and Seal Secret

sealed-secret.yaml:

Commit sealed secret to Git:

ArgoCD syncs → Controller decrypts → Secret created in cluster

DO: Use External Secrets Operator

For secrets stored in AWS Secrets Manager, Azure Key Vault, HashiCorp Vault, etc.

Install External Secrets Operator

Configure SecretStore (AWS Example)

Create ExternalSecret

Commit to Git (no secrets!):

External Secrets Operator fetches from AWS → Creates Secret in cluster

Disaster Recovery

Backup Strategy

What to backup:

  1. ArgoCD configuration (ConfigMaps, Secrets)

  2. Application CRDs

  3. Git repositories (already backed up)

  4. Cluster state (optional, Git is source of truth)

Backup ArgoCD Configuration

Automated Backup with CronJob

Disaster Recovery Procedure

Scenario: Entire cluster destroyed

This is the beauty of GitOps: Git is the disaster recovery.

Monitoring ArgoCD

Prometheus Metrics

ArgoCD exposes Prometheus metrics by default.

Scrape Configuration

Key Metrics to Monitor

Grafana Dashboard

Import official ArgoCD dashboard: ID 14584

Alerting Rules

Troubleshooting Common Issues

Issue 1: Application Stuck in Progressing

Issue 2: Sync Takes Too Long

Issue 3: Out of Sync but Looks Identical

Issue 4: Secret Sync Failures

Production Checklist

Pre-Production

Application Setup

Ongoing Operations

Cost Optimization

ArgoCD Resource Tuning

Application Controller Tuning

Repo Server Caching

Security Best Practices

1. Least Privilege RBAC

2. Network Policies

3. Git Repository Protection

  • Enable branch protection on main/production branches

  • Require PR reviews before merge

  • Enable commit signing

  • Use separate repos for sensitive environments

  • Audit Git access logs

4. Secret Scanning

Performance Tuning

Large-Scale Deployments (200+ Apps)

Key Takeaways

  1. Secret management is critical

    • Never commit secrets to Git

    • Use Sealed Secrets or External Secrets Operator

    • Rotate secrets regularly

    • Audit Git history

  2. Disaster recovery is built-in

    • Git is the backup

    • Restore by re-syncing from Git

    • Test recovery procedures

    • Automate backups of ArgoCD config

  3. Monitor everything

    • Prometheus metrics

    • Grafana dashboards

    • Alert on out-of-sync and unhealthy apps

    • Track sync performance

  4. Production readiness checklist

    • RBAC, SSO, secrets, monitoring, backups

    • CI/CD integration

    • Rollback procedures

    • Team documentation

  5. Scale ArgoCD with your needs

    • 1-50 apps: Default setup

    • 50-200 apps: Scale repo server and controller

    • 200+ apps: Enable sharding, external Redis

    • Monitor and tune

Final Thoughts

GitOps with ArgoCD transformed how we deploy applications:

  • Before: 2 AM deployments, manual kubectl commands, configuration drift, rollback panic

  • After: Git push, automated deployment, zero drift, confident rollbacks

The investment:

  • 2 weeks initial setup

  • 1 week team training

  • Ongoing: ~2 hours/week maintenance

The return:

  • 90% reduction in deployment time

  • 100% deployment audit trail

  • Zero configuration drift incidents

  • Disaster recovery in minutes

  • Sleep at night

Start small:

  1. Install ArgoCD

  2. Deploy one app

  3. Add second environment

  4. Integrate CI/CD

  5. Expand to more apps

GitOps is a journey. This series gave you the map. Now go build!


Previous: GitOps CI/CD Pipeline Integration Back to: GitOps 101 Overview

Last updated