QUICK START:HTMLCSSJavaScriptTypeScriptPythonSQLReactNext.jsNode.jsLinux & UbuntuKotlinSwiftC# / .NETJavaGoRustC++DSASystem DesignDevOpsCybersecurityAI / ML
Advanced 26 min readModule: Module 14: GitOps & Declarative Delivery: ArgoCD & Helm

GitOps Continuous Delivery: ArgoCD, Helm & Self-Healing

Implement modern GitOps delivery pipelines: Git as the single source of truth, ArgoCD Application controller architecture, Kustomize environment overlays (dev/stage/prod), automated drift detection, and self-healing cluster synchronization.

What You Will Learn in This Lesson

  • The 4 principles of OpenGitOps: Declarative, Versioned & Immutable, Pulled Automatically, Continuously Reconciled
  • Why Push CI/CD pipelines (running `kubectl` from Jenkins/GitHub Actions) expose critical security credentials
  • Configuring ArgoCD Applications with automated sync policies, prune, and selfHeal
  • Managing multi-environment Kubernetes configurations using Kustomize overlays

Introduction & Core Concept

In traditional Push-based CI/CD pipelines, build runners in CI (GitHub Actions, Jenkins) require cluster-admin credentials to execute `kubectl apply` directly against production Kubernetes. In the GitOps paradigm, Git is the single source of truth for desired infrastructure state. An in-cluster Pull agent (ArgoCD) continuously monitors Git, detects configuration drifts, and reconciles the cluster to match Git automatically—with zero cluster credentials ever leaving the private network.
WHY DOES THIS MATTER IN THE REAL WORLD?

GitOps provides instant rollbacks via `git revert`, prevents manual configuration drift (hotfixes overridden by CI), and provides a cryptographic audit log of every infrastructure change.

Syntax & Structure

yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: payment-service
spec:
syncPolicy:
automated:
prune: true
selfHeal: true

ArgoCD Declarative Application Manifest with Automated Self-Healing

yaml
yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Declarative ArgoCD Application Manifest (GitOps Single Source of Truth)
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: kwas-core-platform
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
source:
repoURL: 'https://github.com/kwas-academy/infrastructure-gitops.git'
targetRevision: main # Git branch / commit SHA / Helm tag
path: environments/production # Path to Kustomize overlays
destination:
server: 'https://kubernetes.default.svc' # Target In-Cluster API Server
namespace: production
syncPolicy:
automated:
prune: true # Deletes resources from K8s if removed from Git repo
selfHeal: true # Automatically reverts any manual 'kubectl edit' changes!
syncOptions:
- CreateNamespace=true
- ApplyOutOfSyncOnly=true
retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

Line-by-Line Technical Breakdown

1App of Apps Pattern: In enterprise setups, rather than managing 100 individual ArgoCD application YAMLs, teams deploy an 'App of Apps'—a single root ArgoCD Application that points to a folder containing other Application manifests, automating multi-cluster bootstrapping.

Try It Yourself (Interactive Editor)

Modify the code in real-time and click Run to test live browser output and console logs.

Intelligent Code Runner & Live Sandbox[YAML]
YAML SOURCE EDITOR
Interactive Live Code

Common Mistakes & How to Avoid Them

#1: Storing plain-text database secrets in GitOps repositories without cryptographic encryption.

Base64 is encoding, not encryption. Always use SealedSecrets or External Secrets Operator so only encrypted ciphertexts are committed to Git.

Incorrect / Antipattern
apiVersion: v1
kind: Secret
data:
  DB_PASS: cGFzc3dvcmQxMjM= # Decodable base64 in Git!
Correct / Professional Solution
# Use SealedSecrets (Bitnami) or External Secrets Operator with HashiCorp Vault / AWS Secrets Manager

Industry Best Practices & Professional Standards

  • Enable `selfHeal: true` and `prune: true` in production ArgoCD applications.
  • Use Kustomize overlays to share base YAML configurations across dev, staging, and prod.
  • Deploy External Secrets Operator to securely inject secrets from AWS KMS or HashiCorp Vault.

Lesson Summary & Core Takeaways

  • GitOps uses Git as the declarative, auditable single source of truth for infrastructure.
  • ArgoCD pulls changes from Git, preventing cluster credential exposure in CI systems.
  • Automated drift detection and self-healing prevent undocumented configuration drifts.