-
Notifications
You must be signed in to change notification settings - Fork 97
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
[EPIC] - Implement Nebari Secret Management #787
Comments
Vault status updateKubernetes application pods that rely on Vault to manage their secrets can retrieve them directly via network requests or maintained on a mounted file system through the Vault Injector service via annotations or attached as ephemeral volumes. This approach of employing ephemeral volumes to store secrets is a feature of the Secrets Store extension to the Kubernetes Container Storage Interface (CSI) driver. Installing Vault:Vault already provides a very customizable Helm chart for direct installation. There are two ways of providing the necessary configuration:
Management of secrets:Vault has two different ways of creating and managing the secrets: The sidecar method requires init and/or sidecar containers to retrieve secrets. This is done either by adding pod annotations or using configuration maps defining the Vault role and the path to the secret. It increases the total number of containers running in your cluster but provides a Vault agent to template secrets into configuration files and easily enables rotation of those secrets. The CSI method simplifies this architecture since it does not require any sidecar containers. The Vault provider is deployed as a DaemonSet and renders secrets before the pod starts. It also provides a method to sync secrets into environment variables and Kubernetes secrets. Vault authenticationThe primary method of authentication with Vault when using the Vault Agent Injector or the CSI Driver is the service account attached to the pod. For Kubernetes authentication, the service account must be bound to a Vault role and a policy granting access to the secrets desired. When the pod is started it will authenticate with the Kubernetes Auth Method using the service account identity provided in your pod manifest.
Extras
|
Installing Vault with Helm and executing using KubectlPerforming a quick install of Vault can be done by following:
Install the latest version of the Vault Helm chart running in development mode with the injector service disabled and CSI enabled. Adjust
We should be able to inspect the new pods in K9s To set a new secret and inspect the generated secret volume you can follow How to set a secret in Vault With the secret stored in Vault, the authentication configured and role created (below an example from Vault docs):
Proceed to install the vault CSI provider extension
and defines the SecretProviderClass. it is finally time to create a pod that mounts the desired secret:
|
Status report:
Currently, I'm trying to achieve a programmatic creation of secrets within Vault, I`m able to create the secret directly using:
Still uncertain of how Vault will be unsealed when deploying the production server and how we expect to include its secrets, we might need to change the deployment logic a bit. I WIll include a brief report soon |
Summarizing the differences between the Sidecar injector and the CSI driver:
In order to CSI driver work, we need to:
How it all worksWhen the pod is started it will authenticate with the Kubernetes Auth Method using the service account identity provided in your pod manifest. After successful authentication, the secret paths defined in your SecretProviderClass will be retrieved and written to a tmpfs volume and mounted to your pod. |
Due to recent updates on Qhub this was moved to future work and will be added to a future roadmap. |
This is great information! Thanks @viniciusdc! Today I spent sometime researching another proposed alternative, SOPS. SOPS is a much lighter weight option but doesn't come with many of the features that Vault does. SOPS appears to used for decryption during the deployment process, ie decrypt the secret using SOPS and then these returned values can be stored as a Kubernetes Secret . There does exist this terraform provider which will simplify that process but it doesn't fundamentally change how or when SOPS is used. I need to circle back to Vault to see how it compares. |
Today I spent sometime researching and playing with Vault. @viniciusdc provided a lot of great information above but I wanted to summarize a few of my high-level thoughts and findings. Vault's core featuresFor our purposes, the Vault server(s) would run on Kubernetes. This server is responsible for managing and decrypting secrets. Vault is also very often configured to take advantage of some of the following features:
ImpressionsI have to say I'm quite impressed with what I've seen so far. This is obviously a heavyweight application but makes up for it with a lot of awesome features. To me it feels like Vault is to secret management as Keycloak is to identity and access management. That said, this is definitely going to be a heavier lift in terms of development compared with SOPS. But, if done correctly, this will not only harden Nebari from a security perspective but it will also enable greater control over access to external data sources. |
@iameskild my opinion has changed on this. I certainly think that vault is extremely useful but will require a lot of effort to deploy properly and most importantly will only solve the "how to expose secrets to users" not "how to use secrets with a deployment". SOPS has the opportunity to solve both and will be significantly easier to implement. I'm not saying that we never add Vault support but SOPS will be enough to solve the current issues that users have raised with us so I'm in favor of us implementing SOPS. |
I do agree with @costrouc as well. While I still think Vault could be much more accessible for the user to manage (and we could try exposing the secrets using a mix of CSI drives with user-specific mounts), it will be undeniably a pain to integrate with all the Nebari inner services (more refactoring than anything else). Still, the main problem I can foresee with Vault right now is that it will become another "Keycloak" case where we integrate the feature, but we will not be using it to its fullest (while also taking lots of releases to make it stable). So, I am also in favor of implementing SOPS (mainly because it has a terraform provider as well XD) |
This issue is currently being discussed in two RFDs. |
Another options that arised recently, and seems really promissing as we would be able to use keycloaks IAM system to mange user permissions to secrets: They are working on providing support to OIDC, but if they do implement it, could be a good solution for the problems above, as there will be an UI to manage all secrets (kuberntes included) and insert them into user pods/services |
Summary
Currently there is not a robust way of exposing secrets for given users/groups in kuberentes jupyterlab.
Proposed implementation
Using hashicorp vault within the QHub deployment. I see some docs on service accounts and sidecars. Still need to research this implementation further.
[1] https://www.vaultproject.io/docs/platform/k8s/injector
[2] https://www.vaultproject.io/docs/auth/kubernetes
Acceptance Criteria
Tasks to complete
Related to
The text was updated successfully, but these errors were encountered: