When OpenBao Agent caching for leased secrets and tokens is worth enabling
OpenBao Agent's cache sits between local applications and the OpenBao server. It stores tokens and leased secrets that the Agent has already obtained, so repeated requests from the same host can be answered locally instead of each one reaching the server. The case for enabling it is strongest when many processes on one node, or many pods scheduled to one Kubernetes node, ask for the same dynamic credential or token. Each cache hit is a request the OpenBao server does not have to serve and a wait the application does not have to sit through. Teams with high request fan-out, short-lived leases that would otherwise be re-issued often, or latency-sensitive services that open many connections are the most likely to see a clear gain. Workloads that read a secret once at startup will gain little.
The trade-off is that the cache holds live credentials in the memory and storage of the Agent host. Anyone who can read the Agent's process memory, its cache directory or the token it uses to talk to OpenBao can reuse what is cached, so a cached token carries the same authority as the token it came from. Caching also means a lease keeps working on the host until it expires, is renewed or is revoked, so a policy change or revocation may not reach that host as quickly as a fresh request would. Before enabling the cache, confirm which request paths it covers, whether it caches tokens, leases or both, and how revocation affects entries already in the cache in your Agent version.
Use these questions to decide. Do the same secrets get requested often enough that server load or latency matters? Is the host dedicated to the workload that needs those credentials, with file and process access limited to the Agent user? Do you need the cache to survive an Agent restart? Persistent caching on Kubernetes addresses that need, but it also writes cached material to disk, so plan encryption and volume placement before go-live if you choose it. Test restart and revocation behavior in a non-production cluster, and check the OpenBao Agent documentation for the exact cache and persistence settings your release supports.
How requests flow through the Agent cache
The flow starts with an application or template consumer calling the local OpenBao Agent listener on the same pod or host. The Agent checks its in-memory cache for a matching token or leased secret. On a hit, the response returns locally and the OpenBao server sees no request. On a miss, the Agent calls the upstream OpenBao cluster across the trust boundary, then stores the result, and only a persistent cache store, if you configure one, keeps that material on disk. Check where that store lives and who can read it.
Agent cache lookups, upstream misses and the optional persistent store.
Cache configuration options and when each fits
This table compares the main cache choices in OpenBao Agent, including the cache listener, persistence, and how tokens and leases are kept. Read each row as a question to answer for your workload, then confirm the exact configuration keys against the Agent documentation for your release line before you write any configuration.
| Setting or choice | What it does | When it fits | What to confirm |
|---|---|---|---|
| Caching disabled (direct requests) | Each consumer call goes to the OpenBao server, so the server handles every read and renewal. | Low request volume, or a short test where you want to see every API call reach the server. | Expected request rate from all consumers and whether server load or latency is actually a problem. |
| Cache of tokens and leased secrets in memory | The Agent keeps issued tokens and leased secret responses in process memory and serves matching requests locally. | Many short requests for the same secret from one host, where lower latency and fewer server calls matter. | How the cache key is formed for each request, and how cached leases are renewed or evicted. |
| Cache listener for local clients | The Agent exposes a local listener that applications call instead of the OpenBao server address. | Applications that already speak the OpenBao or Vault API and can point at a local address. | Listener address and protection settings, and whether local processes on the host can reach it. |
| Persistent cache across restarts | Cached tokens and leases are written to disk so a restarted Agent can reuse them. | Kubernetes pods or hosts where restarts are frequent and re-authentication load is a concern. | Where the cache file is stored, its file permissions, and how it is encrypted or protected at rest. |
| Token caching only | The Agent caches the tokens it obtains, but secret reads still go to the server. | Workloads that read many distinct secrets and mainly need to limit login traffic. | Whether token renewal from the cache behaves as expected for your auth method. |
| Lease-aware caching of dynamic secrets | Cached dynamic credentials are reused until their lease nears expiry, then renewed or replaced. | Dynamic database or cloud credentials where reusing a valid lease is safer than requesting new ones on every call. | How the Agent handles leases close to expiry and whether revoked leases are dropped from the cache. |
| Cache with an in-memory-only design | Nothing is written to disk, so a restart forces fresh authentication and secret requests. | Hosts with strict rules against secrets at rest, or where restarts are rare. | Startup load on the server after a fleet-wide restart, and how re-authentication is rate limited. |
How the cache treats leased secrets versus tokens
Cached tokens and cached leases follow different rules, and the difference determines how long a cache entry can be trusted. A token has its own time-to-live and can be renewed until it reaches its maximum lifetime. A lease is attached to a specific secret, such as a dynamic database credential, and OpenBao revokes it automatically when its time-to-live runs out. The leasing model with automatic revocation is described in What is OpenBao. The practical rule is that a cached entry must never outlive the lease or token behind it. Before you enable caching for a secret type, confirm in the Agent documentation for your release how renewal is scheduled and what the cache does when renewal fails.
Caching a leased credential also shares it. Every process that reads the secret through the same Agent receives the same lease, so all of them share one identity in the audit log and one revocation outcome. If an operator revokes that lease, or a bulk revocation ends the leases under a role, every consumer loses the credential at the same moment, and the cache entry must be dropped or it will keep serving a dead credential. Test this on a non-production role: revoke a lease by hand, then check that the Agent stops serving it, that the next read fetches a fresh lease, and that the application logs a clear error. Confirm whether your Agent version evicts entries on revocation or only on expiry.
Decide cache scope by secret type and consumer count. Long-lived static secrets gain the most from caching and carry the least renewal risk, while short-lived dynamic credentials need the closest review, because a cached copy with little remaining lease can expire in the middle of a request. Give separate applications their own roles or paths when accountability matters, since a shared lease collapses separate consumers into one identity. Write a runbook that covers an Agent restart with a populated cache, a single lease revocation and a bulk revocation, and rehearse it before go-live. Confirm the cache persistence settings for your platform before you rely on them after a restart.
Setting up the Agent cache step by step
This sequence takes an OpenBao Agent from a bare install to a cache that serves tokens and leased secrets to local applications, with a check at each stage so you know the cache is working before any workload depends on it.
Confirm the OpenBao version and Agent role
Record the OpenBao server version your cluster runs and the exact Agent binary version you plan to deploy, and confirm both appear in the release notes for your target line before you configure anything. Decide which host or pod will run the Agent and which applications will call it. Your platform or security team typically owns this decision, and the output is a short written record of server version, Agent version and the list of consumers. Check that the Agent can reach the OpenBao API address over the network path your environment allows. The step is done when you can run a status call from the Agent host and get a healthy response from the server.
Configure auto-auth for the Agent
Choose the auto-auth method that fits the platform, such as AppRole for servers or Kubernetes auth for pods, and create the matching role on the server with a policy limited to the secrets the consumers need. Add an auto-auth block to the Agent configuration and point its token sink at a file readable only by the Agent's service account. The Agent logs in and writes a token to the sink. The check is that the Agent log shows a successful authentication and that the token file exists with restrictive permissions. Do not proceed until the token is accepted, because the cache depends on it for every request it proxies.
Enable the cache and the local listener
Add a cache stanza and a listener on a loopback address or a Unix socket that only local consumers can reach, following the Agent configuration reference for your version. Keep the listener off public interfaces, since anything that reaches it can use the Agent's token. Restart or reload the Agent and confirm it starts without configuration errors. The check is that the listener accepts a connection from the consumer host and that the Agent log reports the cache is enabled. Confirm the exact configuration keys for your version against the documentation before you write them into production files.
Decide on cache persistence
Decide whether cached tokens and leases should survive an Agent restart. A persistent cache stores data on disk so a restarted Agent can resume without re-authenticating every consumer, but the stored material is sensitive and needs file permissions, encryption at rest and a retention policy. An in-memory cache leaves nothing on disk but forces re-login after each restart. On Kubernetes, confirm the volume type and whether it is shared between containers before you choose. Record the decision and the storage location in your runbook. The step is complete when the chosen setting is in the configuration and the owner has signed off on where sensitive cache data lives.
Point consumers at the local listener
Change each application's client address to the local Agent listener so requests go through the cache rather than directly to the OpenBao server. Remove any static token or direct server address from the application configuration in the same change, so the application does not bypass the Agent. Review which requests your application makes repeatedly, because those are the ones the cache will serve. The check is that a test request from the application succeeds and that it no longer contains a direct server address or a long-lived token in its configuration. Keep a rollback path that restores the previous address in case a consumer depends on a behavior the Agent does not proxy.
Verify cache hits and renewal behavior
Send the same read request twice through the listener and compare the Agent log and the server audit log to confirm that the second request is served from the cache and does not produce a new server read. Then check renewal: for a leased secret, confirm the Agent renews or re-fetches before the lease expires, and for the token, confirm it renews automatically. Test a controlled Agent restart and observe whether consumers recover with or without re-authentication, matching your persistence decision. The step is done when hit behavior, renewal timing and restart recovery all match the design you recorded in earlier steps.
Persistent caches on Kubernetes and what they change
A persistent cache matters on Kubernetes because the cache normally lives with the pod, and pods restart often. An in-memory cache starts empty after a restart, so the Agent must authenticate again and fetch every leased secret it needs. During a node drain or a rolling deploy, many pods can restart at once, and that burst of logins and reads adds load to the OpenBao cluster at the moment the workloads most need their secrets. Persisting the cache lets a restarted Agent reuse a token and leases that are still valid, which avoids part of that burst. Whether that benefit is worth the added risk depends on your token TTLs and how often your pods are replaced, so measure restart behavior in a test cluster before you decide.
The cache store is written to a path that the Agent container can reach, either on the container's writable filesystem or on a mounted volume. A path on the container filesystem survives only container restarts within the same pod, so it does not help when Kubernetes replaces the pod. A volume lasts longer, and its type decides how long the data survives and whether other containers in the pod can read it. Confirm with your cluster team the volume type, whether it follows the pod to a new node, the file mode and ownership the Agent needs, whether the data is encrypted at rest on the node, and what removes the volume when the workload is deleted. Check the persistence settings in the OpenBao Agent documentation for your version, since the exact keys and options must match the release you run.
Cached tokens on disk are bearer credentials. Anyone who reads the file can use the token until it expires or is revoked, so the cache changes your risk from process memory to whatever can reach the volume. Node compromise, backup tools that snapshot persistent volumes, and workloads that share a volume all widen that exposure. Reduce it by mounting the cache only into the Agent container, keeping token TTLs short, scoping the auto-auth role's policies tightly, excluding cache volumes from backups, and revoking tokens when a workload is decommissioned. Record the decision for each workload: a persistent cache is a reasonable choice for a service with heavy secret reads and a tightly controlled node pool, and a poor one for a workload that runs on shared nodes with broad access.
Questions teams ask before enabling Agent caching
What drives the cost of an Agent caching project?
The main cost is the engineering and review time to design, test and roll out caching, because OpenBao itself is licensed under MPL-2.0 and carries no license fee. Cost rises with the number of Agent deployments, how many applications share each Agent, the number of leases and tokens involved, whether caches must persist on Kubernetes volumes, and how much internal change review your organization requires. The rollout is a one-time cost. Ongoing support, upgrades and retesting recur if you choose a retainer. Ask for a quote built from a written scope that lists each workload, environment, deliverable and review step.
How long does an Agent caching rollout usually take?
The timeline depends on the work, not on caching alone. The factors that move it most are the number of consumers and Agent instances, the auth method each one uses, whether test environments already mirror production, and how often your change windows open. Teams that already run OpenBao and have a clear inventory of consumers move faster than teams that must first map which applications read which secrets. Ask for a timeline in the written scope with milestones for testing, restart validation and production rollout, and confirm which dates depend on your approvals.
What does our team need to provide for caching work?
You need to provide access to a non-production OpenBao environment that matches production closely enough to test caching, along with administrative access to the cluster and to the platform that runs the Agents. You also need an inventory of applications, the auth method each Agent uses, the secrets and leases each application depends on, and any Kubernetes details if caches will persist in volumes. Name the people who approve configuration changes and the windows when production changes are allowed. Missing inventory data is the most common reason a scope grows.
Can our own platform team enable Agent caching without a partner?
Yes, if your team already operates OpenBao and understands how tokens, leases and renewals behave in your applications. Your team will need to test restart behavior, token expiry and failure paths in a lab before changing production. The decision usually depends on skills and capacity, not on the feature itself. Consider a partner if nobody on your team has tested Agent restarts, if you lack a lab that resembles production, or if your review process requires independent evidence. Compare an internal estimate with a fixed-scope quote before deciding.
What happens to cached tokens when an Agent restarts?
The exact behavior depends on your OpenBao version, Agent configuration and where the cache is stored, so confirm it against the OpenBao Agent documentation for the version you run before you rely on it. Test a restart in a lab with the cache populated and check three things: whether cached tokens and leases are reused or refetched, how consumers recover while the Agent restarts, and whether any renewal or revocation happens during the gap. Record the results and repeat the test after every upgrade.
Does caching increase the security exposure of tokens and secrets?
It can, because the cache holds tokens and leased secrets that would otherwise exist only briefly in an application's memory. Limit who can read the cache directory or volume, restrict file permissions on the host, and encrypt the volume where the cache persists. Keep token policies narrow, so a cached token can read only what its consumer needs. Review how long leases last and whether revocation reaches the cache. Your security team should threat-model the cache location before the rollout, and the results should be written into the design.
Does Agent caching replace a highly available OpenBao cluster?
No. Caching reduces how often Agents call the server for tokens and leased secrets, but it does not remove the need for the server to be available when a cache entry expires or must be renewed. OpenBao high availability uses one active node that holds a lock in the data store, with standby nodes that forward or redirect requests. Confirm which reads still reach the cluster during an outage, and keep your cluster design based on the high availability guidance in the OpenBao documentation.
Do we need a compliance or audit review before enabling caching?
Many regulated organizations require an internal change review for any change that affects how secrets reach applications, and caching falls into that category. Ask your compliance lead which evidence the review expects, such as the design, access controls on the cache, test results for restarts and audit log coverage. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or attestations, which come from independent auditors or certification bodies. Plan the review time as part of the project scope.
Security risks of caching tokens and leased secrets
A client-side cache holds live tokens and leased secrets outside the server's direct control, so every cached credential is a copy that must be protected, bounded and traceable. The cards below cover where those copies sit, how far a single token reaches, and how to confirm that revocation and audit still reflect what the Agent is doing.
On-disk cache exposure
When persistent caching is enabled, tokens and leased secret responses can be written to disk so they survive an Agent restart. Anyone who can read that location can use the credentials until they expire or are revoked. Before enabling persistence, confirm exactly which objects the cache writes, where the path points, and whether the directory is shared with other workloads or included in node snapshots and backups.
Shared token blast radius
A cached token is only as narrow as the policies attached to the identity that created it. If several containers, processes or templates share one Agent cache, a compromise of any one consumer exposes everything that cache can serve. Map each Agent to a single workload identity, review the policies on that identity, and avoid granting one Agent broad read access just because several applications run beside it.
File permissions and volume encryption
Cache files and their parent directories should be readable only by the Agent's service account, with ownership and mode set explicitly rather than inherited from a default umask. On Kubernetes, the cache volume's backing storage determines whether data is encrypted at rest. Ask the platform team whether the volume is an emptyDir on node disk, a network volume or a memory-backed mount, and whether that storage is encrypted.
Token revocation and cached copies
Revoking a token in OpenBao invalidates it on the server, but copies held by the Agent or the cache must be dropped or refreshed to stop use from the client side. Test the revocation path end to end: revoke a token used by a running Agent, confirm the Agent stops serving it, confirm the cache entry is removed, and confirm the consuming application fails in a controlled way instead of retrying with a stale copy.
Lease and restart behavior
Leased secrets keep working only until their lease ends, and a persisted cache can carry a lease into a restarted process. Verify how the Agent behaves when it restarts with cached entries whose leases are close to expiry or already expired. Write down the expected result for each case, including whether the Agent fetches fresh credentials or serves the old ones, so that a restart does not extend the life of a secret you meant to retire.
Monitoring cache-driven access in audit logs
Requests the Agent makes with its own token appear in OpenBao's audit log under that identity, but reads served from the local cache do not generate new server requests. That gap makes it harder to see which application used a secret. Confirm your audit device captures the Agent's token and lease activity, define which lease and token events trigger alerts, and review whether the Agent's identity can be tied back to each workload that consumes its output.
What happens to cached secrets when the Agent restarts
Treat an Agent restart as a cache reset until staging proves otherwise. The Agent's client-side cache of tokens and leased secrets is the layer most likely to be lost, so the first decision is whether your deployment keeps that cache in memory or writes it to a persistent location. An in-memory cache disappears with the process, which means every consumer behind the Agent may request fresh tokens and secrets at the same moment. Confirm in staging how many requests reach the OpenBao server in the first minute after a restart, and whether that load plus your applications' startup retries stays within what your cluster can absorb. Also confirm which leases the Agent had been renewing, because any lease it no longer tracks will run down on its own schedule.
After a restart, the auto-auth block runs again and logs in with the configured method, such as AppRole, Kubernetes or a token file, to obtain a new token. Test three things in staging: that the credential for that method (a role ID and secret ID, a service account token or a token file) is still available to the restarted process, that the new token lands in the sink you expect, and that renewal begins without manual steps. If the credential was rotated, revoked or reached a usage limit during the outage, the Agent cannot log in, and no cached secret will fill the gap. Check the Agent logs and the OpenBao audit log for failed logins so you can separate a credential problem from a network problem.
Consumers recover only when they can read the Agent's output again. Applications that read a rendered file or token sink often keep working through a restart if that file persists on disk, but a consumer that reads from an ephemeral location fails until the Agent rewrites it. Decide for each consumer whether a short gap is tolerable, whether the application retries reads, and whether a readiness check should wait for the first successful render. In Kubernetes, confirm the pod restart order and whether a sidecar restarts with its application, since that ordering changes what the application sees. Record the file paths and permissions observed after each restart test so the runbook matches what actually happens.
Limits to confirm in your environment
Agent caching behavior depends on the OpenBao release line, how the Agent is supervised, how templates consume secrets, and whether namespaces are in use. Confirm each of these against your own environment and the release notes before you size caches or write restart runbooks.
Supported OpenBao release line
Start by pinning the exact minor and patch version you will run, then confirm the caching and Agent behavior you plan to depend on is documented for that line. The project's current releases include v2.7.0 (September 23, 2026), v2.7.1 (October 1, 2026) and v2.6.4 for the previous minor line. Confirm details of the v2.7.x releases against the release notes before you treat them as the baseline, and record which line your patch policy will follow.
OpenBao releasesVersion-specific cache changes
Cache handling and Agent options can change between minor lines, so an upgrade may alter what is cached, how long entries live or which keys are accepted. Ask for the change log between your current and target versions and test cache behavior on a staging Agent before promoting. Note any deprecated configuration keys that your Agent files still use.
Process supervisor and template interaction
When the Agent runs a child process in supervisor mode or re-renders templates, cached leases can be renewed, re-read or invalidated in ways that affect the child. Confirm whether a restart of the child or a template change flushes the cache, and whether the child sees stale values during that window. Test this with the same template and exec settings you will ship.
Cache sizing and eviction
Cache capacity should be set from the number of distinct tokens, leases and secret paths your Agent serves, not from a guess about traffic. Measure lease counts under expected load, check memory limits on the host or pod, and confirm how the cache behaves when it fills. Ask the vendor or project for documented sizing guidance before you set limits.
Namespace behavior
If you use namespaces for tenant isolation, confirm that cached tokens and leases are keyed to the correct namespace and that a cached entry cannot be served to a caller in another namespace. Run a test where two namespaces request the same secret path through one Agent. Record the result for your access review.
Namespaces docsPersistent cache and restart behavior
Persistent caches on Kubernetes can keep tokens and leases across Agent restarts, which changes who can read that storage and how long credentials remain valid. Confirm the cache file location, its permissions and encryption at rest, and what the Agent does with entries it cannot renew after a restart.
How DeployOpen scopes and delivers Agent caching work
DeployOpen plans and implements OpenBao Agent caching inside your own infrastructure, so the cache, its persistence and its restart behavior are written down and tested before applications depend on them. Each engagement starts from a written scope that names the workloads, the leased secrets and the cache settings involved.
How we scope
- Inventory which applications would read through Agent and which leased secrets and tokens each one needs
- Confirm the OpenBao version, auth method and cluster topology the Agent will connect to
- Record whether the cache stays in memory or uses a persistent cache on Kubernetes, with the reasons
- Agree in writing the restart, token renewal and lease expiry tests that define completion
How we build
- Configure the Agent cache listener, auto-auth and token sinks on hosts or pods you control
- Set cache and persistence paths with file permissions that match your host hardening standard
- Test that cached tokens and leases renew, expire and revoke as the OpenBao policies require
- Run load and latency comparisons against a direct OpenBao connection to confirm the cache helps
How we hand over
- Deliver the Agent configuration, cache settings and service definitions as version-controlled files
- Document what the cache holds on disk, what is lost on restart and how to clear it safely
- Provide a runbook for rotating auth credentials and recovering from a stale or corrupted cache
- Walk your platform and security teams through the test results and the remaining open risks
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing are available as a retainer
- Re-test cache behavior when the OpenBao version or Agent configuration changes
- Confirm with the OpenBao project and your own environment any version-specific cache behavior before upgrading

