kustomize-controller: SOPS doesn't work with overlay patches
It doesn’t seem possible to have a kustomization overlay patch encrypted with SOPS. It seems like the patch is applied before SOPS decrypts the secrets, which means SOPS won’t be able to decrypt the final merged secret.
Here’s an example:
https://github.com/apeschel/flux-testing/tree/main/secrets
Trying to use this on a cluster results in the following error:
my-secrets False decryption failed for 'basic-auth': AES decrypt: Error walking tree: Could not decrypt value: Could not decrypt wit
h AES_GCM: cipher: message authentication failed main/4f9cfd2077e624ab97ac63b79f5a38946e080cf4 False
Here’s some details
- SOPS decrypts both basic-auth.yaml and patch.yaml file with no issues locally
kustomize buildis able to render the YAML fine locally, albeit encrypted.- flux is able to decrypt and deploy basic-auth.yaml fine as long as the patch isn’t enabled.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 5
- Comments: 15 (12 by maintainers)
Commits related to this issue
- sops encrypted patches are not a good idea see https://github.com/fluxcd/kustomize-controller/issues/344 — committed to cubic3d/ops by cubic3d 5 years ago
I think this does actually work.
I have a base yaml file with no encrypted data in it.
I then patch that with a patechesStrategicMerge with sops encrypted values ( with individual keys encrypted not the entire file ) and kustomize successfully reconciles in the cluster.
Going one step further I have yet another kustomization over the top, and here’s where the caveat exists. If I have any encrypted value in the previous overlays I need to make sure those keys are overwritten ( even if it’s the same data ) or kustomize cannot decrypt it, but this doesn’t stop me patching any other keys.
Working for me using 0.16.1.