How do you store secrets in Git safely for GitOps?
IntermediateProductionSecrets and Credentials
Answer
Never commit plaintext. Options: External Secrets Operator (Git holds only an ExternalSecret that references a path in Vault or AWS Secrets Manager), Sealed Secrets (encrypt with a cluster public key; only the cluster controller can decrypt), or SOPS with KMS/age keys (encrypted values in YAML, decrypted by Flux or an Argo CD plugin). We prefer External Secrets because rotation happens in the secret manager with no Git change.
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata: { name: db-creds }
spec:
secretStoreRef: { name: aws-sm, kind: ClusterSecretStore }
target: { name: db-creds }
data:
- secretKey: password
remoteRef: { key: prod/shop/db, property: password }
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you manage application secrets from build to runtime?IntermediateHow do you detect secrets committed to a repo?BeginnerWhat do you do after a secret is committed to Git?IntermediateHow do you use HashiCorp Vault with CI/CD?AdvancedHow do you rotate a credential used by dozens of pipelines without downtime?Advanced