Interview Prep/DevSecOps/Secrets management: Vault, External Secrets and SOPS

Flux Kustomization fails with `decryption failed for 'db-secret': ... failed to get the data key required to decrypt the SOPS file`

IntermediateTroubleshootingSecrets management: Vault, External Secrets and SOPS
Answer

Likely causes → spec.decryption is missing from the Kustomization, the referenced secret is in the wrong namespace, or the age key in it is stored under a key name that does not end in .agekey.

Diagnose →

flux get kustomizations -A
kubectl get kustomization apps -n flux-system -o yaml | yq '.spec.decryption'
kubectl get secret sops-age -n flux-system -o jsonpath='{.data}' | jq 'keys'

Fix →

kubectl create secret generic sops-age -n flux-system \
  --from-file=age.agekey=./age.agekey
spec:
  decryption:
    provider: sops
    secretRef: { name: sops-age }

Prevent → Bootstrap the decryption secret as part of cluster provisioning, and keep its private key in a cloud secret manager.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets management: Vault, External Secrets and SOPS