Cloud & DevOps
GitOps Continuous Delivery with ArgoCD: Multi-Cluster Application Synchronization
Traditional push-based CI/CD pipelines (e.g., executing kubectl apply from CI runners) introduce substantial security risks: granting long-lived cluster administrator credentials to external build tools and failing to detect unauthorized manual cluster mutations. GitOps flips this paradigm into a declarative pull model where Kubernetes clusters continuously reconcile their live operational state against a single source of truth stored in Git. ArgoCD stands as the industry standard for managing declarative multi-cluster application delivery at scale.
Managing Hundreds of Clusters with ArgoCD ApplicationSets
Rather than managing individual Application manifests for each target cluster, the ApplicationSet controller uses generators (Git directory, Cluster list, Matrix) to automatically instantiate applications across dynamic fleet environments:
# applicationset-multi-cluster.yaml
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: core-microservices
namespace: argocd
spec:
generators:
- clusters:
selector:
matchLabels:
environment: production
template:
metadata:
name: '{{name}}-billing-service'
spec:
project: default
source:
repoURL: 'https://github.com/efektifpro/gitops-deployments.git'
targetRevision: HEAD
path: 'apps/billing/overlays/{{name}}'
destination:
server: '{{server}}'
namespace: billing
syncPolicy:
automated:
prune: true # Automatically prune resources deleted from Git
selfHeal: true # Overwrite manual out-of-band cluster modifications
syncOptions:
- CreateNamespace=true
Progressive Delivery with Argo Rollouts & Canary Analysis
Pairing ArgoCD with Argo Rollouts replaces standard Kubernetes RollingUpdates with automated canary deployments evaluated against Prometheus metrics (e.g., error rate < 0.5%):
| Deployment Step | Canary Traffic Weight | Prometheus Analysis Gate | Duration |
|---|---|---|---|
| Step 1 | 10% | Verify HTTP 5xx error rate < 0.1% | 10 minutes |
| Step 2 | 33% | Verify P99 response latency < 250ms | 15 minutes |
| Step 3 | 100% (Full Promotion) | Complete roll forward; retire old ReplicaSet | Immediate |
- Self-Healing Infrastructure: With
selfHeal: trueenabled, any accidental manual edits via kubectl are instantly reverted to match the canonical Git commit. - Sync Waves and Hooks: Use
argocd.argoproj.io/sync-waveannotations to guarantee database schema migrations run and succeed before application pods deploy. - Secret Management via SealedSecrets / External Secrets: Keep Git repositories 100% public or internal without exposing plaintext secrets by using HashiCorp Vault or AWS Secrets Manager integrations.
