Lesson 4 of 9 · 27m
Secrets Management Without Pretending Git Is a Vault
Compare SOPS, External Secrets, and Sealed Secrets by control-plane properties, rotation behavior, blast radius, and day-two operations.
Every GitOps program eventually hits the same uncomfortable sentence: "but the secret has to be in the repo somewhere." No, it does not. The declaration that a secret exists can live in Git. The secret material should either be encrypted with tightly controlled keys or never stored in Git at all. The correct design depends on who may decrypt, how rotation works, and how much damage a leaked repository clone can do.
Three common shapes
SOPS encrypted secret material committed beside config
External Secrets references to secrets stored in an external manager
Sealed Secrets cluster-scoped encrypted secret material for one controllerThese are not interchangeable products. SOPS keeps data encrypted at rest in Git but requires key management. External Secrets keeps Git as a pointer system and relies on the external provider as the source of secret truth. Sealed Secrets is operationally simple but couples ciphertext usability to controller keys and namespace/name scope.
SOPS with age is explicit and auditable
A representative .sops.yaml:
creation_rules:
- path_regex: clusters/prod/.*[.]secret[.]yaml$
age: age1ql3z7hjy54pw3hyww5acyy3s2c5d5l0xptx3n3m5h0w5x7q0h5kqsx0p6yEncrypt only secret files, and encrypt the data or stringData fields rather than the whole object when you want metadata diffs to remain reviewable:
sops encrypt --in-place clusters/prod/payment.secret.yamlThe operational question is not "is it encrypted?" It is "who can decrypt production, from where, with what audit trail?" If every developer laptop can decrypt production, the encryption mostly protects the repository host, not the organization.
External Secrets keeps secret truth outside Git
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata: {name: payment-api, namespace: checkout}
spec:
refreshInterval: 1h
secretStoreRef: {kind: ClusterSecretStore, name: aws-secrets-manager}
target: {name: payment-api, creationPolicy: Owner}
data:
- secretKey: stripe_secret_key
remoteRef: {key: prod/checkout/payment-api, property: stripe_secret_key}Git now declares the relationship, not the value. Rotation can happen in AWS Secrets Manager, and the controller refreshes the Kubernetes Secret. But now the external store and its IAM policy become critical security infrastructure. Test restores, audit access, and alert on sync failure.
Rotation is a workload problem too
Updating the Kubernetes Secret is only half the job. Many applications read secrets once at startup. If nothing restarts or reloads them, rotation is a time bomb. Understand whether your platform uses checksum annotations, reloader controllers, native watch behavior, or deliberate rolling restarts.
A common implementation is a checksum/payment-secret annotation rendered from the secret version or material. Do not fake it by changing the value manually; derive it in the deployment pipeline.
Kubernetes Secrets are not a security boundary by themselves
Base64 is encoding, not encryption. Anyone with get secret RBAC in the namespace can read the value. etcd encryption protects at rest but does not stop authorized API readers. GitOps controls reduce plaintext sprawl; they do not replace least privilege.
Field notes
- Never commit plaintext because "we will rotate it later"; repository history is forever unless rewritten.
- Exclude decrypted files with pre-commit hooks such as
gitleaksand SOPS-aware tooling, but treat scanning as a safety net rather than design. - Test disaster recovery: a secret system that cannot be restored is an outage generator.
- Avoid committing both ciphertext and decryption keys to the same effective trust domain.
- Secret sync failure often looks like an application failure. Monitor controller status before restarting random pods.
Was this lesson helpful?