sops: decrypt on every Flux Kustomization + static guard against the silent ENC[...] trap #66
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_0fe36052"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
spec.decryptionis opt-in per Flux Kustomization, and its failure mode is silent: asecret-*.sops.yamlunder a tree without the block is still valid YAML, so Flux applies theSecret with literal
ENC[AES256_GCM,…]values and reports success. The Secret is green andwrong, and the first symptom is an application failing to authenticate days later, looking
nothing like a git problem. Only
appsandmonitoringcarried the block; the other six treeswere a trap for whoever added a Secret there next.
decryption: {provider: sops, secretRef: {name: sops-age}}tocert-manager,databases,gateway-api-crds,infrastructure,loggingandflux-system→ 8/8 Kustomizations decrypt now; harmless where no encrypted files exist. The block in
flux-system/gotk-sync.yamlis hand-added on top of the generated manifest (a futureflux bootstrapdrops it — the guard catches that).scripts/check-sops-decryption.py+make check-sops: static guard (no cluster, no age key,no network) that reads the live sync path out of
clusters/*/flux-system/gotk-sync.yaml,walks each Kustomization's kustomize resource graph, and fails when a
*.sops.yaml/*.sops.ymlfile (a) sits under a tree whose owner cannot decrypt, (b) sits under no reconciled tree, or
(c) contains no
sops:block /ENC[AES256_GCM…— plaintext wearing an encrypted name..gitattributesmarks*.sops.yamlwithdiff=sopsdiffer(opt-in textconv, documented);docs/secrets-sops.mdexplains the opt-in trap, the eight Kustomizations and the guard.Verification on this branch
Synthetic case (introduced, exercised, removed — tree clean afterwards):
plus a plaintext file named
secret-plaintext-test.sops.yaml→FAIL … no SOPS ciphertext (ENC[AES256_GCM...) — is the value plaintext?/missing the 'sops:' metadata block.A Flux-equivalent
kustomize buildofclusters/homek8s(auto-generated resource list) renders8 Kustomization objects, all with
provider: sops.Out of scope, untouched
No secret contents, recipients or keys changed; no secret moved between trees;
flux-system/sops-ageuntouched; no
kubectl create secret.`spec.decryption` is opt-in per Flux Kustomization, and a secret-*.sops.yaml under a tree without it is still valid YAML: Flux applies the Secret with literal ENC[AES256_GCM,...] values and reports success. The Secret is green and wrong, and the first symptom is an auth failure days later that looks nothing like a git problem. Only `apps` and `monitoring` had the block; the other six trees were a trap for the next person to add a Secret there. - add decryption: {provider: sops, secretRef: sops-age} to cert-manager, databases, gateway-api-crds, infrastructure, logging and flux-system (8/8 Kustomizations now decrypt; harmless where no encrypted files exist) - scripts/check-sops-decryption.py + `make check-sops`: static guard that reads the live sync path from gotk-sync.yaml, walks each Kustomization's kustomize resource graph, and fails when a *.sops.yaml file is under a tree whose owner cannot decrypt, is under no reconciled tree, or is not actually encrypted (also catches `flux bootstrap` regenerating gotk-sync.yaml without the block) - .gitattributes marks *.sops.yaml with diff=sopsdiffer; docs/secrets-sops.md explains the opt-in trap, the eight Kustomizations and the guard No secret contents, recipients or keys touched.