Secrets for Kubernetes, stored encrypted in Git
Lose a cluster.
Keep every secret.
Keyfold seals each secret once — to every cluster that needs it and to an offline recovery key. A controller in each cluster turns it into a Secret. Add or replace a cluster without re-encrypting a single value; lose a cluster, a controller or a key, and recover everything from the repository and any one key that's left.
A CRD and a controller. No vault, no external store, no network hop in the decrypt path.
$ keyfold seal -n prod --name db --keyring envs/prod/keyring.yaml \ --from-env-file db.env > deploy/prod/db.yaml $ keyfold recipients list -f deploy/prod/db.yaml 76FF43EB…4DBB9F25F controller 8841CF5F…8307FB2C recovery $ kubectl get gitsecret -n prod NAME TARGET READY KEYS RECIPIENTS AGE db db True 2 2 9s $ keyfold recipients add $CLUSTER_B -f deploy/prod/ --write … added: 14 changed, 0 already done, 0 skipped $ GNUPGHOME=~/recovery keyfold unseal -f deploy/prod/db.yaml --key DB_PASSWORD hunter2
Why Keyfold
No single key, cluster or service to lose
Most ways of putting secrets in Git hang everything on one controller key or one external service. Keyfold wraps each secret's key to several independent recipients instead — and keeps the parts that matter visible in review.
Any one key brings it all back
A controller, an operator and an offline recovery key can each decrypt on their own. Lose any of them — or every cluster — and the repository plus one remaining key recovers everything, offline, with keyfold unseal.
Grant access without re-encrypting
Adding a cluster rewraps one small key per object. The encrypted values don't change, so the diff is a one-line recipient change — across a whole directory in one command.
A CRD and a controller
Ciphertext lives inline in a GitSecret object and arrives like every other manifest — your GitOps tool or kubectl apply. The controller never clones a repository or calls out.
Who can decrypt is in the diff
spec.recipients, their roles and the commit a secret was sealed from are plain fields — and columns in kubectl get gitsecret.
Ciphertext only opens where it was sealed
Each value is authenticated against its namespace, object and key. Copied into another object, it fails to decrypt instead of quietly applying there.
Loss is cheap. A leak is not.
Multiple recipients make a lost key a routine change. A leaked key still means rotating the secrets it could read — the docs say exactly which step protects what.
The mechanism
How it works
One random content key per secret, encrypting the values; that key wrapped separately to each recipient. Concepts has the whole model on one page.
Seal
keyfold seal encrypts each value with a fresh content key (XChaCha20-Poly1305, bound to namespace/name/key) and wraps that key to every recipient in your environment's keyring — public keys only.
Commit
The GitSecret manifest holds only ciphertext, the recipient list, and the commit it was sealed from. Git is the source of truth; review it like any other change.
Apply
Your GitOps tool or kubectl apply delivers it — no Keyfold-specific integration, no plugin in the sync path.
Reconcile
Each cluster's controller unwraps the content key with its own GPG identity and writes the target Secret. Objects not wrapped to it stay untouched — it holds no master key.
encryptedData every value, sealed with one random content key encryptedKey that content key, wrapped to each: cluster A · cluster B operator · offline recovery recipients the same list, in plain text
Clusters, people and keys over time
Every change is one command — and says what it changes
Only an existing recipient can grant access: a new cluster's public key alone can never add itself.
| When | Run (as an existing recipient) | What changes |
|---|---|---|
| Add a cluster | keyfold recipients add <fpr> --role controller -f deploy/prod/ --write | The wrapped key only. No value re-encrypted. |
| A cluster or its key is lost | Install a new controller identity, then recipients add it and recipients remove the old one | The wrapped key only. |
| Someone leaves | recipients remove <fpr>, then keyfold rekey | New content key; values unchanged. |
| A key leaked | Rotate the secret at its source, then printf %s "$NEW" | keyfold set KEY -f db.yaml | The value itself — the only step that protects what was exposed. |
| No cluster left | keyfold unseal -f db.yaml with any recipient key | Nothing — values printed to stdout. |
Runbooks: multi-cluster · recipient lifecycle · disaster recovery.
Security model
What it defends — and what it doesn't
Defended
- Losing any one key, controller or whole cluster
- Ciphertext copied into another object or repository
- Plaintext in logs, events, status or metrics
- A secret that only one machine could ever decrypt
- Silently clobbering a
SecretKeyfold doesn't own - A tampered keyring: https only, every embedded public key checked against its fingerprint
Not defended — by design
- History: a leaked key reads every version it was ever a recipient of — rotate the secrets
- A cluster admin who can already read
Secrets - A compromised operator workstation
- Rollback to an older committed version (visible, not prevented)
Nothing in the cluster serves plaintext on request; the controller decrypts only into Secrets. Full analysis: threat model · decision records.
Get it
Install
On Kubernetes
# the cluster's own GPG identity — only its private key goes in
kubectl create namespace keyfold-system
kubectl -n keyfold-system create secret generic keyfold-gpg \
--from-file=private.asc=controller.asc
helm install keyfold oci://ghcr.io/opscalehub/charts/keyfold \
--version 0.12.0 --namespace keyfold-system \
--set gpgPrivateKey.existingSecret=keyfold-gpg
- Runs under Pod Security
restricted; signed images and chart; caches only the Secrets it manages - Optional: admission webhook, public-key publishing, sealing UI
- Chart README · quickstart
The CLIs
keyfold— seal, recipients, unseal, rekey, migrategit-keyfold— encrypted files in a repository (git keyfold …)kubectl-keyfold— encrypted values in a plainSecretmanifest- From GitHub Releases: linux & macOS (amd64, arm64), windows (amd64), each with a
.sha256 - From source (Go 1.26+):
go install ./cmd/...
gh attestation verify ./keyfold-linux-amd64 --repo OpScaleHub/keyfold cosign verify \ --certificate-identity-regexp '^https://github.com/OpScaleHub/keyfold/' \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ ghcr.io/opscalehub/keyfold-controller:<tag> # same flags for ghcr.io/opscalehub/charts/keyfold:<version>
Without Kubernetes
Encrypted files in any repository
git keyfold installs git hooks that encrypt matched files on commit and decrypt them on checkout — plaintext in your working tree, ciphertext in history, push blocked if plaintext slips through. Same envelope; its own key per repository, wrapped to each teammate's GPG key.
git keyfold init --key-backend gpg --gpg-recipient <you> --gpg-recipient <teammate> git add .keyfold.yml .keyfold/key.gpg .gitignore && git commit -m "configure keyfold" echo "password: hunter2" > secrets/db.yaml git add secrets/db.yaml && git commit -m "db credentials" # ciphertext in history git keyfold adduser <new-teammate> # rewrap, no file re-encrypted
Getting started with the Git plugin · command reference · kubectl keyfold
Read more
Documentation
- Start — Concepts · Kubernetes quickstart · Git plugin
- Operate — Multi-cluster · Recipient lifecycle · Disaster recovery · Troubleshooting · Upgrading
- Reference — keyfold & controller · Helm chart · Keyring files
- Design — Architecture · Threat model · Decision records · Reporting a vulnerability