How to Configure Oc Create Token Duration

Published
Length
3 min read

Luis Felipe Dias

All posts

The oc create token duration setting controls how long an OpenShift service account key stays valid. You set it up by requesting a bound key from the cluster API with a short time limit. Modern OpenShift clusters use the TokenRequest API to issue time-bound keys. Old versions made static secrets that never expired. Now, teams can ask for a key that dies after a set time. This change reduces the risk of leaked keys in build logs or local files. How oc create token duration works for cluster wo

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

The oc create token duration setting controls how long an OpenShift service account key stays valid. You set it up by requesting a bound key from the cluster API with a short time limit.

Modern OpenShift clusters use the TokenRequest API to issue time-bound keys. Old versions made static secrets that never expired. Now, teams can ask for a key that dies after a set time. This change reduces the risk of leaked keys in build logs or local files.

How oc create token duration works for cluster workloads

When you run the command to make a key, the cluster talks to the API server. You pass a target service account name and a time value. The API server checks your permissions before it builds the key. It then signs a JSON Web Token with an expiration timestamp.

This setup affects both human users and automated apps. Engineers often generate a temporary key to test a role from a local machine. External CI pipelines also use these keys to deploy apps into a namespace. Every workload that uses this method gets a key bound to its specific service account.

The cluster enforces safe defaults even if you do not specify a time. If you ask for a very short time, the cluster raises it to a minimum floor. If you ask for too much time, the cluster caps it at the system limit. You should always ask for the shortest time needed to finish the task.

Bound keys also link to the life of the service account itself. If an admin deletes the service account, the key stops working right away. This behavior gives teams a fast way to cut off a compromised workload. You do not need to wait for the clock to run out during an incident.

How to check keys and handle session gaps

You can check the life of any issued key by inspecting its payload. Standard decoding tools show the exact issue time and expiration time inside the token claims. Cluster admins should also review API server audit logs on a regular schedule. These logs show which user asked for a key and what time limit they set.

Token Rotation + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Auditing helps you spot teams that ask for multi-day keys out of habit. You can then guide those teams toward shorter limits for daily tasks. Role-based rules can also restrict who has the right to request new keys. Only trusted admins and deployment tools should hold that permission in production namespaces.

Still, a short time limit only controls when a session can start and end. Once a user or script logs in with a valid key, the cluster trusts every allowed command. Native cluster settings do not inspect the content of database queries or shell commands inside pods. A valid key with broad permissions can still read sensitive tables or delete resources.

Further, sharing service account keys across a team hides who ran a specific action. The cluster audit log only sees the service account name, not the human engineer. If a key leaks, anyone can use it until the timer expires. Teams must pair short token lifetimes with strict role rules and user-level tracking.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What happens when a service account token expires during a task?

The API server rejects any new requests made with that expired key right away. Long-running scripts must request a fresh key before the old one runs out. Watching processes or active streams may also drop when the key passes its time limit.

Can I revoke a time-bound token before its timer runs out?

You cannot revoke a single stateless token by itself without affecting the whole account. To kill the token early, you must delete and recreate the service account. You can also remove the role bindings from that service account to block its actions.

Why did the cluster give me a shorter token than I asked for?

The cluster API server enforces a maximum token lifetime set by the platform admin. If your request exceeds that ceiling, the server lowers the duration to match the cluster rule. Check with your platform team to learn the maximum allowed time for your cluster.

The query runs. The emails stay hidden.