-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Best practices for handling secrets in kustomize #4633
Comments
@btrepp: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
We use https://external-secrets.io/v0.5.3/, a CRD that creates "native" secrets from other types.
Hope that helped :) |
Kustomize indeed has features that help to create secret resources from data, but does not have any opinions or functionality around helping you secure that data before (or after!) Kustomize interacts with it. Indeed Kubernetes secrets themselves are not ideal in terms of security (see all the caveats in those docs). There are many different approaches to either avoiding the use of k8s secrets in favour of a first-class secret store, or securing them as much as possible, and I'm not really in a position to advise on them. Sealed Secrets is an example of the latter that has documented Kustomize support. Kustomize's scope eliminates most options for being more helpful, since we cannot shell out to other tools or call external APIs for both security and design constraint reasons. SecretGenerator used to support external commands, but that was removed for security reasons. The issue for the removal spawned a lot of discussion that might be of interest to you: #692. The external plugin option (3) is probably the closest we could get to supporting more sophisticated integration with various secret handling solutions folks are using, and once the KRM Functions Registry is stood up, it could be a logical home for such plugins. |
I had experimented with some of those tools, but found a few short comings with the kustomize plugins, and the k8s operators. I ended up writing https://git.sr.ht/~btrepp/kubepassgen and a gitops plugin for argocd https://git.sr.ht/~btrepp/argo-pass-sidecar I believe this tool keeps the kustomize spirit of 'no templates' as much alive as possible. I can use this to have secretGenerator generator empty secrets, and then patch them 'at the last second' by creating a new kustomize file.
This is working in my home lab cluster, and is great because I don't have to rely on a cloud operator. Passwordstore supports git, and I have a private git server. So I just mainly glue existing tools together :). I'm okay with closing this issue, though I think the root of 'best practice' is still probably not yet clear for kustomize. So there good be value in further discussion. |
For anyone coming upon this thread, I've had a lot of success on past projects with something called sops, from mozilla. https://github.com/getsops/sops the principal is that you encrypt your secrets using keys that sops controls (the keys may be in something like KMS from GCP for example). and commit the encrypted file to the repo. there are then plugins for kustomize + sops such as this https://github.com/viaduct-ai/kustomize-sops that decrypt the secrets at deploy time from the file and build them into versioned k8s secrets. It's probably the best deployment strategy for this stuff I've come across. |
Hi All,
I really love the tool, and do understand the core philosophy of 'everything should come from the files'.
However theres a bit of a grey area when it comes to secrets.
Most kustomize code, is most likely checking into git.
Kustomize pushes you to include every thing into files.
Secrets are an important part of any app.
Thus the logical solution here is that kustomize is driving you to 'put your secrets in your git repository'.
Years of that being a bad idea have somewhat stuck with me. There appear to be a few hacks here, eg
At the moment, the most sane seems to be 2, combining kustomize with another tool that can generate the secrets and using that to overlay the actual app, but that does get a bit complex with maybe multiple kustomization files being needed then.
The motivation for asking is to help solve argoproj/argo-cd#9083, but there are a few ways that could be done.
Is there any guidance for how secrets should be used with kustomize?. It's an amazing tool, and a solution that keeps the secrets using a hash, thus helping the deployments change is amazing.
The text was updated successfully, but these errors were encountered: