-
Notifications
You must be signed in to change notification settings - Fork 173
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
Sidecar Overwrites Secrets Generated By Init Container #162
Comments
As a quick fix I decided to add the following annotation: vault.hashicorp.com/agent-pre-populate: "false" This way, the init container is not run anymore, however, my application containers fails a couple times until the sidecar initially fetched the secrets. Surely not an ideal solution. |
Hi @borchero, we've run into this issue in similar setups. One (albeit hacky) workaround is to add a delay before your application runs, something like: command: ["/bin/sh"]
args: ["-c", "sleep 5; ./app"] |
Thanks for your suggestion. I think my temporary solution is safer though (as there is no "right" duration to sleep since fetching the actual credentials could obviously take longer). Do you already have a fix on your roadmap? Otherwise, I might open a PR in the near future. |
We've discussed some possible solutions, and sidecar container ordering may end up solving this for us (kubernetes/enhancements#753), but PRs are welcome! |
I got hit by this, for a while now we had a random weird issue where some services would start and then throw a bunch of errors after 1 hour when they failed to connect to consul. I finally found the time to setup the audit log for Vault and after that quickly found that not one but two consul tokens where issued on each pod startup, looking at the To be honest I just don't get the defaults, you can get use Vault for two main reasons:
Instead of having bot containers why not just choose one and disable the other by default and add a big warning in the documentation ? It took me far too much time to diagnose this issue and I even doubted Vault as a whole where in fact it ended up being only a dubious default configuration choice and a lack of documentation issue. If the default was to not have the init container it would have taken me far less time to notice that the file wasn't available yet and in fact I fixed that issue even before it could even occurred by waiting for the file to appear, it just requires basic kubernetes knowledge to know that all containers in a pod will start at their own pace with no relation to the others. I hope a solution is found to avoid others this kind of disagreements, it is already a complex enough system to setup as it is. PS: the 1 hour above was the TTL of the consul token |
@tvoran I did not notice this but my point still holds since its default is |
@schmurfy Sure, and I think in the future we will default persistent caching to |
can we change this to default to true now? |
Describe the bug
I am currently experiencing an issue where I request dynamic database credentials from Vault. The init container initially fetches the credentials and correctly stores them. When the main container starts up, it reads the contents of that file and can connect to the database. However, the sidecar refreshes the secret and apparently uses a new lease for obtaining database credentials. The file is therefore overwritten, only the new (unused) credentials are continuously extended and the client loses access after an hour (the credential's TTL).
To Reproduce
Expected behavior
The sidecar container should use the same token as the init container for obtaining database credentials.
Environment
The text was updated successfully, but these errors were encountered: