-
Notifications
You must be signed in to change notification settings - Fork 4.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
agent: persistent caching support #10938
Conversation
Adds the option of a write-through cache, backed by boltdb
b003bfb
to
49ce6e6
Compare
jason's renaming suggestions Co-authored-by: Jason O'Donnell <[email protected]>
* Gate routing template through cache * Fix tests * Update changelog * Update changelog/10927.txt Co-authored-by: Calvin Leung Huang <[email protected]> Co-authored-by: Calvin Leung Huang <[email protected]>
AuthLeaseType = "auth-lease" | ||
|
||
// TokenType - Bucket/type for auto-auth tokens | ||
TokenType = "token" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this bucket is carved out for the auto-auth token, but can that be stored in the root directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps? Though I left it as a separate bucket since this is how the cachememdb behaves, namely old auto-auth tokens are not removed if a new one comes in, and they aren't expired. So I added this bucket out of abundance of caution, in case a lease that needed to be restored relied on a previous auto-auth token.
Since we're not rotating root buckets or anything, no need to have a separate storage area.
The sub-buckets off root were no longer necessary, so renamed "root" to "meta" and moved the other token and lease buckets up so they're all at the top level.
Moved getServiceAccountJWT() to agent, renamed and made LeaseCache.restoreLeaseRenewCtx() private, and checking for unexpected type in LeaseCache.hasExpired().
Adds the option of a write-through cache to the agent, backed by boltdb, with the aim of preserving the renewal of leases and tokens across agent restarts.
This functionality is configured through a new
persist
stanza within thecache
portion of the vault agent config file:The persist
type
specifies the key protection scheme to use for the key encrypting/decrypting the persisted data. Currently "kubernetes" is supported, where the encryption key is saved in the boltdb, using the service account jwt as the AAD (extra data) used to encrypt and decrypt.service_account_token_file
is optional, and defaults to "/var/run/secrets/kubernetes.io/serviceaccount/token"The
path
parameter is required, and is the file system location to write the cache db file. The file name for the cache file isvault-agent-cache.db
. So in the above example the full file and path would be/path/to/db/vault-agent-cache.db
.If
keep_after_import = false
, the db file will then be deleted after importing, and agent tokens and secrets will only be cached in memory.If
exit_on_err = true
, errors during import of an existing db cache will cause the agent to exit.The bolt db is laid out in multiple buckets:
version: 1
entry for use in the future if migrations are required. It also contains the most recent auto-auth token cached by the agent, and the key material used to decrypt and restore an existing cache. This key material may either be the key, or some other token used to retrieve the key.