Course contentsShow
← Cloud and Infrastructure
Lesson 1870 of 2,98939. GitOps PrinciplesFree lesson

Handling Secrets in GitOps

Manage sensitive data in GitOps workflows using encryption, sealed secrets, or external secret stores.

Handling Secrets in GitOps

You'll learn how to safely manage sensitive data like passwords and API keys in GitOps workflows without exposing them in Git repositories.

The Core Challenge

GitOps relies on Git as the single source of truth for your infrastructure—but Git repositories are fundamentally designed for transparency and version control, not for storing secrets. Committing plaintext passwords, database credentials, or API tokens directly into Git creates massive security risks. Anyone with repository access (or anyone who compromises it) gains access to your secrets.

Think of it like writing your house alarm code on a sticky note attached to your front door. Sure, you know where to find it, but so does everyone else.

Solutions for Secret Management

Encryption at Rest

Tools like SOPS (Secrets OPerationS) or git-crypt encrypt secret values directly in your Git repository. The files remain in Git (maintaining GitOps principles), but they're encrypted using keys stored elsewhere (like AWS KMS or GPG). The reconciliation loop decrypts them during deployment.

Sealed Secrets

Sealed Secrets (commonly used with Kubernetes) lets you encrypt secrets into "SealedSecret" resources that can safely live in Git. Only the cluster with the private key can decrypt them. You commit the sealed version; the cluster unwraps the actual secret.

External Secret Stores

Instead of storing secrets in Git at all, reference them from external vaults like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault. Your Git repo contains only references or paths; the actual secrets live in a dedicated, hardened secret store. The reconciliation agent fetches secrets at deployment time.

Choosing an Approach

  • Encrypted in Git: Best for audit trails and disaster recovery
  • External stores: Best for dynamic secrets and fine-grained access control

Key Takeaway: Never store plaintext secrets in Git; use encryption (SOPS, Sealed Secrets) to keep secrets in GitOps repos safely, or externalize them entirely to dedicated secret management services.