Short-lived Kubernetes service account tokens from OpenBao

OpenBao's Kubernetes secrets engine issues Kubernetes API credentials on demand with set TTLs and cleans them up when leases expire. This page covers what it does, when to use it, and what to confirm before rollout.

On this page

Short-lived Kubernetes service account tokens from OpenBao: when teams need them

Teams need short-lived Kubernetes credentials when CI jobs, operators or automation call the Kubernetes API with service account tokens that were created once, copied into pipeline variables and never rotated. Those tokens are hard to revoke without breaking every job that depends on them, and nobody can easily say which system still holds one. The Kubernetes secrets engine in OpenBao addresses this by issuing Kubernetes API credentials on demand, so each caller receives a credential that is created when requested and expires on its own schedule. It fits the same leasing model OpenBao uses for dynamic database credentials: each issued credential carries a lease, and OpenBao revokes it automatically when the lease ends or when an operator revokes it in bulk.

Before you design around this engine, decide which workloads actually need Kubernetes API access from outside the cluster. Typical cases include a deployment pipeline that applies manifests, a support engineer who needs read access to one namespace, or an operator that manages resources across clusters. For each case, list the roles it needs, the namespaces and resources it touches, and how long a credential should remain valid. Those answers map directly onto the engine's roles and role bindings, and they show whether a generated service account or an existing one is the better fit. The exact token TTL behavior, the options for generated service accounts and how role bindings are expressed should be confirmed against the current OpenBao documentation for the version you plan to run, since these details change between releases.

Also confirm how the cluster side is prepared before you rely on the engine. OpenBao must hold a credential that allows it to create and clean up the service accounts, roles and bindings it manages, so review the privileges that credential carries and where it is stored. Kubernetes stores Secrets unencrypted in etcd by default, so the configuration OpenBao uses to reach the cluster deserves the same attention as any other sensitive credential. Ask your platform team to confirm the cluster's encryption at rest and RBAC settings, and test one full cycle in a non-production cluster: issue a credential, use it, let the lease expire, and confirm that the associated objects are removed.

How a workload gets a short-lived Kubernetes token from OpenBao

The flow starts when a client asks the Kubernetes secrets engine in OpenBao for a credential under a named role. OpenBao calls the Kubernetes API server, which creates the token or generated service account, and returns it to the client with a lease. The trust boundary sits between OpenBao and the cluster: OpenBao needs a credential that is allowed to create tokens, so confirm its RBAC scope. When the lease expires or is revoked, OpenBao removes the generated objects, so check that cleanup happens as you expect.

Token issuance and lease-driven cleanup across the OpenBao and cluster trust boundary.

Configuration options and when each fits

This table compares the main configuration choices for the OpenBao Kubernetes secrets engine: token lifetime, existing versus generated service accounts, role definitions, bindings and the cluster connection. Read each row for the situation where it fits and the trade-off you accept. The main takeaway is that the service account choice and binding scope determine most of the blast radius, so settle those before tuning lifetimes.

Configuration choiceWhen it fitsTrade-off to accept
Token TTL (short lifetime)Workloads that run briefly, such as CI jobs or one-off admin tasks, where a credential should expire soon after useClients must request new credentials more often, and long-running jobs need a renewal or re-request step
Token TTL (longer lifetime)Operators or tools with long-running sessions that cannot easily re-request credentialsA leaked token stays valid longer, so the lifetime should match the risk of the task
Existing service accountA namespace already has a service account with a tested RBAC set and the team wants to reuse itPermissions are shared with other workloads, and changes to that account affect every consumer
Generated service accountEach issued credential should map to its own identity with narrow permissions, and audit trails must separate each useRoles must be planned carefully, and the cluster needs RBAC that lets OpenBao create and remove the account
Role definition (namespace and resources)Scoping a role to one purpose, such as read-only access to a single namespaceOverly broad role definitions are common, so each role needs a named owner and a review step
Role binding to namespaces or subjectsLimiting which namespaces or identities may request credentials from a roleBindings that are too wide let unrelated teams obtain access, and bindings that are too narrow cause support requests
Kubernetes connection settings (API address and CA)A single cluster with a stable API endpoint and a CA that OpenBao can verifyChanges to the API endpoint or CA during cluster upgrades break issuance until the configuration is updated
Kubernetes connection credentials (OpenBao's own access)OpenBao runs inside or next to the cluster and needs permission to manage service accounts and tokensThe privilege OpenBao holds is high, so confirm its exact RBAC needs for your version before deployment

Setting up the Kubernetes secrets engine step by step

This sequence takes an OpenBao cluster from a disabled secrets engine to a verified credential that expires and is cleaned up. Each step ends with a check you can run, so a failure appears at the step that caused it. Teams can repeat the path in a staging cluster before any production role is granted.

  1. Enable the Kubernetes secrets engine

    A platform administrator with OpenBao policy rights mounts the Kubernetes secrets engine at a path your team chooses, such as kubernetes/. If you manage several clusters, use one mount per cluster so each has its own configuration and roles. Done when the mount appears in the list of enabled secrets engines and reading its configuration path returns without an error.

  2. Create a least-privilege identity for OpenBao

    In the target cluster, a cluster administrator creates a dedicated service account for OpenBao and grants it only the API permissions the engine needs to create and delete the credentials you plan to issue. Confirm the exact verbs and resources required for your OpenBao version in the engine documentation. Review the cluster RBAC bindings for this account now, because every role that uses the configuration inherits its reach. Check the result with kubectl auth can-i for each verb and record the output in your change record.

  3. Configure the connection to the Kubernetes API

    The administrator writes the API server address and the cluster's CA certificate into the engine configuration, along with the credential OpenBao uses to call the API. Pinning the CA certificate lets OpenBao verify the API server it talks to. If the API endpoint sits behind a load balancer, confirm the address and port your cluster serves, such as port 6443 in the kubeadm high availability layout. Done when a read of the configuration returns your settings and a test call through the engine completes without error.

  4. Define a role and its bindings

    Create a role that names the target namespace, the service account or generated account the credential uses, and the Role or ClusterRole bindings it receives. Scope the role to one namespace and the narrowest permissions the consuming workload needs. Confirm whether your engine version generates the account and bindings or attaches to existing ones, because that decides what you review in the cluster. Done when a read of the role matches what you approved and kubectl get rolebindings in the namespace shows the expected bindings.

  5. Request a test credential

    A tester with a limited OpenBao policy requests a credential from the role's credentials path and records the token, lease ID and TTL in the response. Use a throwaway namespace and a read-only action for the first run so any mistake carries little risk. Done when the request returns a token and a lease, the TTL matches the value you configured, and a test call with the token succeeds for an action inside the role and fails for one outside it.

  6. Confirm the lease and token permissions

    Look up the lease and check its TTL, whether it is renewable, and the role it came from. Then run kubectl auth can-i with the issued token against a permission the role should not hold and confirm the answer is no. If an audit device is enabled, find the entry for the request and confirm it shows the role and path used. Done when the lease details match the role definition and the out-of-scope check is denied.

  7. Confirm cleanup after lease expiry

    Wait for the lease to expire or revoke it explicitly, then confirm the token no longer authenticates against the API. Check that any service account or binding the engine created for the lease has been removed, using kubectl get serviceaccounts and kubectl get rolebindings in the test namespace. Confirm on your version how cleanup behaves for accounts you pre-created. Done when the lease lookup reports it as gone and no generated objects remain. Anything left behind is a finding to resolve before production roles are issued.

Security and operational risks to control

Issuing cluster credentials on demand concentrates risk in one place: the OpenBao identity that can mint them. The cards below cover what that identity can reach, how generated accounts are scoped, how lease lifetimes are managed, what gets logged, and how failures in the cluster API affect issuance, renewal and cleanup.

OpenBao's own cluster privilege

To create service accounts, tokens and role bindings, the OpenBao connection identity needs RBAC permissions that are powerful inside the cluster. Anyone who can use the secrets engine can, in effect, request credentials with those permissions. Check which namespaces and verbs the identity holds, confirm that it cannot grant itself broader rights, and restrict who can read or write the engine's configuration in OpenBao.

OpenBao namespaces docs

Least-privilege RBAC for generated accounts

Each role should map to the narrowest set of Role or ClusterRole bindings the workload needs. Avoid binding generated accounts to cluster-admin or broad wildcard rules, since a leaked token then carries that reach. Review role bindings during design, and confirm that list and watch access to Secrets follows the least-privilege guidance in the Kubernetes Secrets good practices.

Kubernetes Secrets good practices

Lease and TTL hygiene

Short TTLs limit exposure only if leases are actually tracked and revoked. Set maximum TTLs for each role, decide whether callers may renew, and test that expired leases remove the generated service account or token. Ask your team how long any manually created objects persist and who is alerted when cleanup fails.

Audit logging of issued credentials

Every issuance, renewal and revocation should be traceable to a caller, role and time. Enable an OpenBao audit device before the engine goes live, send logs to storage that the platform team cannot silently alter, and confirm that the logs record credential requests without storing the token values themselves. Map those events to a Kubernetes audit policy so both sides tell the same story.

Cluster API unreachable during renewal

If the Kubernetes API is down or unreachable from OpenBao, renewals and revocations can fail while issued credentials remain valid until their TTL ends. Decide how long a credential may outlive a failed revocation, document the recovery steps, and rehearse them. Confirm the expected behavior in your OpenBao version's documentation and in a test cluster before relying on it.

Encryption at rest for Secrets

Generated tokens are still exposed if they are copied into Kubernetes Secrets, which are stored unencrypted in etcd by default. Configure encryption at rest for etcd, restrict who can read Secrets, and avoid writing dynamic credentials into long-lived objects. Confirm with your Kubernetes distribution how its etcd encryption and backups are configured, since that decides what an etcd backup exposes.

Secrets good practices

When to use this engine instead of Kubernetes auth

The first decision is direction. OpenBao's Kubernetes auth method lets a workload running in a cluster log in to OpenBao using its own service account token, so the pod reads secrets that OpenBao already holds. The Kubernetes secrets engine works the other way: a caller asks OpenBao for a fresh credential that the Kubernetes API will accept, and OpenBao creates that credential and revokes it when the lease ends. Choose the secrets engine when the thing that needs access is a client of the Kubernetes API, not a pod that needs a password or key from OpenBao. Typical cases include a CI job that applies manifests, an operator or controller that reads cluster state from outside the cluster, and an engineer's tool that needs scoped, time-limited cluster access.

Use Kubernetes auth for ordinary workloads that call databases, APIs or other services. Their identity is the pod's service account, and the secrets they read stay in OpenBao's key/value or dynamic secrets engines. Using the secrets engine for those workloads would add a token-issuing step without a clear gain. The two can also work together: a CI pipeline may authenticate to OpenBao through an auth method and then request a Kubernetes credential through the secrets engine, so the pipeline's own identity is still the thing that gets audited and revoked.

Before you commit, confirm three things in your environment. First, which Kubernetes API operations the issued identity must perform, since the role's bindings determine that and should be the narrowest set that works. Second, whether your clusters accept the token types and TTL settings you plan to use, which you should verify against the configuration guidance in the Kubernetes authentication documentation and the OpenBao secrets engine documentation for your release. Third, who can request credentials and whether those requests are logged in your audit device. Settle these questions first, because they decide whether the secrets engine reduces standing access or simply moves it.

Limits to confirm in your environment

Dynamic Kubernetes credentials depend on the OpenBao release, the Kubernetes release and how the cluster handles tokens and service accounts. The cards below list the points to confirm in a lab before any production workload depends on this pattern.

Version pairing

Check the OpenBao release you plan to run against the Kubernetes minor version in your clusters. OpenBao v2.7.1 and v2.6.4 were released on the same day, and v2.7.1 is the current patch in the line this page covers. On the Kubernetes side, the project maintains the three most recent minor releases, and the version skew policy limits how far kubelets can lag behind the API server. Confirm both sides of that pairing with your own upgrade calendar.

Skew policy

Generated service account behavior

When the secrets engine generates a service account, the object and its binding depend on what the Kubernetes API accepts for that release. Test creation, binding and deletion on each Kubernetes minor version you run, including the clusters you keep on older lines. Record which permissions OpenBao needs to create and delete service accounts, and confirm that a failed cleanup is visible to your operators.

Token TTL against cluster settings

Requested token lifetimes are capped by the API server and the cluster's configured maximum, so a role TTL can be shortened without an error. Compare the lifetime OpenBao asks for with the lifetime the token actually receives, and confirm the lease expiry matches. Also check how the token behaves after the lease ends, since a token that outlives its lease weakens the revocation model.

Multi-cluster routing

Each Kubernetes API endpoint and its CA need their own configuration, and a role in one cluster must not issue credentials for another. Confirm which OpenBao mount, role and endpoint serves each cluster, and test that a request routed to the wrong cluster fails. Mixing clusters behind one load balancer or DNS name can send lease revocation to a different control plane than the one that issued the token.

Lease cleanup under failure

Automatic cleanup runs when a lease expires or is revoked, but an OpenBao outage, an API server outage or a permission change can leave resources behind. Simulate each case in a lab: restart the OpenBao leader during a lease, revoke the Kubernetes API credentials, and remove the role permissions. Record what remains and how your team finds it.

Documentation gaps to test

Some behavior is not fully described in the documentation you will read first, including exact field handling for generated accounts on specific Kubernetes versions and error messages during partial failure. Treat each gap as a test case with a written expected result, and ask the vendor or project to confirm anything that the lab cannot settle. Keep the results with the change record for your security review.

OpenBao auth docs

Questions buyers ask before using the Kubernetes secrets engine

What does this engagement cost, and what drives the price up?

The price follows from the written scope, and DeployOpen does not publish a price list. The main cost drivers are the number of clusters that will request credentials, how many roles and role bindings must be designed, whether the Kubernetes secrets engine must work with an existing OpenBao auth model, and how much testing and documentation your audit or security team expects. Setup work is one-time, while operating the engine and reviewing roles over time is recurring. When you ask for a quote, request a line for design, build, verification and handover, and ask which items recur, such as retainer support or retesting. Compare the quote against the scope, not the headline total.

How long does a pilot take before it is ready for production?

Duration depends on how many clusters and namespaces are in scope, how many distinct consumers need credentials, and how quickly your Kubernetes RBAC owners and OpenBao administrators can review proposed roles. A useful pilot covers one cluster, one or two roles, token TTL testing and a confirmed cleanup when leases expire. Ask for a written timeline in the scope document that lists each approval gate. No fixed duration is stated here because no researched figure applies to your environment.

What must our team provide before the work starts?

Three groups of people and access are needed. First, cluster access for the engineers doing the build, ideally to a non-production cluster that matches production's Kubernetes version and API server settings. Second, named RBAC owners who can confirm which service accounts may request credentials and which Roles or ClusterRoles the generated accounts may hold. Third, OpenBao administrators who can create the secrets engine mount, policies and auth configuration. Ask DeployOpen to list these owners in the statement of work so approvals are not blocked later.

Can our own platform team build this without outside help?

Yes, if your team already operates OpenBao and understands Kubernetes RBAC, service account tokens and lease behavior. The harder parts are designing least-privilege roles, deciding which identities may request credentials, and proving that expired leases remove what they created. Teams new to OpenBao or to Kubernetes RBAC often benefit from an external review of the design before go-live. Your team should own the operating model either way, so ask for documentation that your staff can run without the partner.

How does this engine fit with OpenBao auth methods we already use?

The Kubernetes secrets engine handles a different job from the Kubernetes auth method. The auth method lets pods log in to OpenBao, while the secrets engine lets an authorized identity request a short-lived Kubernetes API credential. OpenBao documents a range of auth methods, including AppRole, JWT/OIDC, Kubernetes and TLS certificates, and the project recommends AppRole for servers. Confirm which identities already log in with which method, then map which of them may call the engine and under which policies. Policy overlap is the most common source of surprise access.

What happens to credentials when a lease expires?

OpenBao supports leasing with automatic revocation and bulk revocation, so a credential issued with a lease is removed when that lease ends or is revoked. Engineers should test this directly: issue a credential with a short TTL, confirm the Kubernetes identity works, wait for expiry, and confirm the identity and its bindings are gone. Ask how the design handles renewals, failed revocations and clusters that are unreachable during expiry, because those cases decide whether cleanup is reliable.

What does support look like after go-live?

Most engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts. Ongoing support, upgrades and continuous testing are available as retainers. After go-live, your team typically needs help reviewing roles when workloads change, applying OpenBao and Kubernetes version updates, and checking lease cleanup after cluster changes. Kubernetes releases about three times per year, and the project maintains the three most recent minor releases, so ask how upgrades to both platforms will be tested and who approves them.

What a DeployOpen engagement on this feature covers

A DeployOpen engagement on OpenBao's Kubernetes secrets engine starts with a written scope that names the clusters, the OpenBao instance and the workloads that will receive credentials. The first step is an inventory of every workload that currently needs Kubernetes API access, including CI runners, controllers, operators and internal tools that read or write objects through a service account. For each one, the inventory records what it calls, which namespaces and resource types it touches, whether it needs cluster-scoped permissions, and how it authenticates today. This inventory is the basis for deciding which callers should receive generated, short-lived service accounts and which should stay on existing identities, and it is where the team confirms the Kubernetes versions and distributions in use so the configuration matches what the cluster supports.

Role design is the core review. DeployOpen works through the kubernetes/roles paths, the service_account_name, kubernetes_role_name and kubernetes_role_type settings, and the role bindings that map each OpenBao role to the permissions it grants, with the default TTL and maximum TTL chosen per workload. The review checks that bindings are scoped to specific namespaces, that cluster role bindings are justified case by case, and that lease durations match how long each job actually runs. The output is a reviewed role catalog that the client approves before anything is applied. Configuration then runs in the client's own cluster and OpenBao environment, using the client's change process, and the engagement records the exact settings applied so the client's team can reproduce them.

Test evidence is prepared for the client's security review. Typical evidence includes a test run showing a credential issued with the expected TTL, a denied request from a role that lacks permission, and proof that generated service accounts and their bindings are removed when the lease expires or is revoked. Findings are logged with fixes and retests where needed. Handover covers an operating runbook, the list of roles and owners, and the procedure for adding a workload. Ask any provider to state in writing which items are one-time deliverables and which need an ongoing retainer, and to confirm which OpenBao and Kubernetes versions the test evidence will cover.

How DeployOpen scopes, delivers and supports OpenBao on Kubernetes

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, including OpenBao's Kubernetes secrets engine for short-lived service account tokens. The work starts with a written scope covering which clusters, roles and workloads will receive credentials, and it ends with a tested handover your team can run.

How we scope

  • Inventory which clusters, namespaces and workloads will request short-lived Kubernetes credentials from OpenBao.
  • Define roles, role bindings and the TTL and max TTL each consuming workload actually needs.
  • Agree in writing whether a generated service account or an existing one will back each role, and who owns it.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we build

  • Configure the Kubernetes secrets engine against your cluster API endpoint, with the minimum permissions OpenBao needs to create and clean up tokens.
  • Set up OpenBao auth so workloads reach their roles through their own identity, not shared credentials.
  • Test lease expiry and automatic cleanup in a non-production cluster before any production role is enabled.
  • Check permissions and token lifetimes against your Kubernetes version and the security controls you have agreed to meet.

How we hand over

  • Document each role, its bindings, TTL settings, owners and the workloads that depend on it.
  • Deliver runbooks for revoking leases, rotating the OpenBao configuration and investigating a failed credential request.
  • Walk your platform and security teams through the configuration and the evidence of the cleanup tests.
  • Prepare the configuration and test records that your compliance and security reviewers can examine.

How we support

  • Ongoing support, OpenBao and Kubernetes upgrades and continuous security testing are available as retainers.
  • Re-check role permissions after Kubernetes upgrades, since the supported versions and token behavior can change over time.
  • Review new OpenBao releases that affect the Kubernetes secrets engine and plan the upgrade with your change process.
  • Confirm the support terms, response expectations and out-of-scope items in the written agreement before work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.