--- title: "GitOps Overview" description: "Git-driven Kubernetes deployments for Pangolin and Newt using Argo CD or Flux." --- import PangolinCloudTocCta from "/snippets/pangolin-cloud-toc-cta.mdx"; GitOps is a declarative approach to infrastructure management where your Git repository is the single source of truth for cluster state. Changes go through Git; the GitOps tool automatically reconciles the cluster to match. ## What is GitOps? GitOps reconciliation loop: **Git repository** contains desired state (manifests, Helm values, Kustomize overlays). **GitOps tool** (Argo CD or Flux) watches the Git repository. The controller detects new commits or drift between Git and the live cluster. The controller syncs cluster state to match Git state. **Result**: Cluster stays aligned with the declared Git configuration. ## Benefits - **Version control**: All infrastructure changes tracked in Git - **Audit trail**: See who changed what and when - **Rollback**: Revert to previous state by reverting Git commits - **Automation**: No manual `kubectl apply` commands needed - **Drift detection**: Automatic alerts if cluster diverges from Git ## GitOps tools for Kubernetes ### Argo CD - **UI**: Web-based dashboard for monitoring and manual syncs - **Approach**: External reconciler (watches Git, applies to cluster) - **Supports**: Helm charts, Kustomize overlays, raw YAML - **Best for**: Teams who want GitOps with a UI, hybrid manual/automated workflows **Use Argo CD if**: - You want a visual dashboard - You need frequent manual sync capabilities - You're already using Argo CD for other workloads See: [Argo CD Install Guide](/self-host/manual/kubernetes/gitops/argocd) ### Flux - **CRDs**: Kubernetes-native Custom Resources (HelmRelease, Kustomization, GitRepository) - **Approach**: Declarative reconciliation using Kubernetes resources - **Supports**: Helm charts, Kustomize overlays, raw YAML, OCI registries - **Best for**: Teams who want declarative Kubernetes-way GitOps, lightweight controllers **Use Flux if**: - You prefer Kubernetes-native CRDs - You want a lightweight, modern GitOps tool - You're already using Flux for other workloads See: [Flux Install Guide](/self-host/manual/kubernetes/gitops/flux) ## Recommended repository structure For multi-environment Pangolin/Newt deployments, organize your Git repository like this: ``` my-org/infrastructure/ ├── clusters/ │ ├── production/ │ │ ├── pangolin/ │ │ │ ├── values.yaml │ │ │ └── kustomization.yaml (if using Kustomize) │ │ └── newt/ │ │ ├── values.yaml │ │ └── kustomization.yaml │ ├── staging/ │ │ ├── pangolin/ │ │ └── newt/ │ └── dev/ │ ├── pangolin/ │ └── newt/ ├── apps/ │ ├── pangolin/ │ │ ├── helm/ │ │ │ ├── values-base.yaml │ │ │ ├── values-prod.yaml │ │ │ └── values-staging.yaml │ │ └── kustomize/ │ │ ├── base/ │ │ └── overlays/ │ └── newt/ │ ├── helm/ │ └── kustomize/ └── .gitignore ``` **Pattern**: - `clusters/` → environment-specific configuration - `apps/` → shared, reusable application configuration - Environment overlays layer on top of app definitions ## Secrets in GitOps **Never commit plaintext secrets to Git.** Use secret management tools instead. Options for managing secrets in GitOps: ### Sealed Secrets - **Tool**: [sealed-secrets](https://github.com/bitnami-labs/sealed-secrets) - **How**: Encrypt secrets with cluster-specific key; safe to commit encrypted secrets - **Decrypt**: Only the cluster can decrypt (uses private key) ```bash # Encrypt a secret echo -n mypassword | kubeseal -f - > secret.yaml # Git tracks encrypted secret.yaml # Cluster auto-decrypts on apply ``` ### External Secrets Operator - **Tool**: [external-secrets](https://external-secrets.io/) - **How**: Reference secrets stored in external vault (AWS Secrets Manager, Azure Key Vault, HashiCorp Vault) - **Git**: Stores reference only, not secret values ```yaml apiVersion: external-secrets.io/v1beta1 kind: SecretStore metadata: name: vault-backend spec: provider: vault: server: "https://vault.example.com" ``` ### SOPS (Secrets Operations) - **Tool**: [SOPS](https://github.com/mozilla/sops) - **How**: Encrypt YAML files; decrypt at deploy time - **Git**: Stores encrypted files ```bash sops --encrypt secrets.yaml > secrets.enc.yaml # Commit secrets.enc.yaml; tool decrypts on apply ``` ### Cloud Provider Secrets - **AWS**: Use AWS Secrets Manager or Parameter Store with IRSA (IAM Roles for Service Accounts) - **Azure**: Use Azure Key Vault with pod identity - **GCP**: Use Google Secret Manager with workload identity Choose a secret management strategy **before** setting up GitOps. Seal secrets once; keep approach consistent. ## GitOps workflow example ### 1. Set up Git repository ```bash git clone https://github.com/my-org/infrastructure.git cd infrastructure mkdir -p clusters/production/pangolin cd clusters/production/pangolin ``` ### 2. Create configuration ```bash # values.yaml with Pangolin config cat > values.yaml <=0.1.0" # auto-upgrade to latest 0.1.x ``` ### Drift detection and remediation Argo CD and Flux both support continuous drift detection: - **Argo CD**: Detects drift on demand or continuously; can auto-sync on drift - **Flux**: Reconciles on interval; rolls back manual cluster changes ## Next steps