How to Configure Kubernetes Temporary Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up kubernetes temporary access by creating short-lived role bindings for specific users. When the work finishes, you delete the binding to remove those permissions. Many teams start by giving developers static admin roles to fix live bugs fast. Broad roles stay active forever and leave production pods open to mistakes. A leftover role lets an engineer run bad commands in the wrong namespace. Removing standing permissions shrinks the risk of accidental deletions and data leaks. How to s

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.

You set up kubernetes temporary access by creating short-lived role bindings for specific users. When the work finishes, you delete the binding to remove those permissions. Many teams start by giving developers static admin roles to fix live bugs fast. Broad roles stay active forever and leave production pods open to mistakes. A leftover role lets an engineer run bad commands in the wrong namespace. Removing standing permissions shrinks the risk of accidental deletions and data leaks.

How to set up kubernetes temporary access with native RBAC

Native access control uses roles and bindings in the standard authorization API group. You must turn on the role-based mode on the API server first. A Role holds a set of rules that grant permissions inside one namespace. A ClusterRole holds rules for cluster-wide items like nodes or all namespaces at once. In this system, rules only add permissions, and there are no deny rules. You start with zero rights and add only what the engineer needs today.

To grant access, you create a RoleBinding inside the target namespace. A RoleBinding links a user or group to a Role or a ClusterRole. Even if it points to a ClusterRole, the RoleBinding stays inside that single namespace. If an engineer needs rights across the whole cluster, you use a ClusterRoleBinding instead. For temporary work, an admin or script creates this binding when a ticket opens. When the timer runs out, an external job deletes the binding object.

Managing pod subresources during live sessions

During an incident, engineers often need to read logs or run commands in pods. The API server treats these actions as subresources under the main pod resource. You write the rule with a slash, such as pods and log or exec. If you grant the exec subresource, the user can open a shell inside containers. You can limit a rule to specific pod names using a resource names list. Still, the API server does not apply resource name limits to create requests on subresources. Because of this rule, granting pod exec often opens every pod in that namespace.

What native bindings solve and what they miss

Creating and deleting bindings solves the problem of permanent standing rights in your cluster. Engineers only hold permissions inside the namespace while they fix the active issue. Once your script deletes the binding, the API server blocks new requests from that user. This workflow keeps your permission list clean and helps with basic security checks.

Kubernetes API Server Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, native role bindings only check who can start an API request. They do not inspect what happens inside an open container shell session. Once an engineer opens a pod shell, RBAC cannot filter individual shell commands. The user can read local files, view app secrets, or dump raw customer data. Pod logs and command outputs can also print emails, phone numbers, or card numbers. Native roles cannot rewrite these matched fields in results before they reach the screen. Also, deleting a RoleBinding may not kill an exec stream that is already running. Teams still need a way to check commands in flight and mask sensitive output.

Check Kubernetes API requests and responses on the wire

Kubernetes RBAC decides who may call the API server. RBAC does not check response payloads or split listing Secret names from reading Secret values when a role grants get access. With hoop.dev, you run an open-source proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

On each call, hoop.dev guardrails read the method, normalized path, and headers to refuse bad deletes or full Secret reads with a 403 error, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.

Frequently asked questions

Does Kubernetes have a built-in timer to expire a RoleBinding?

No, native RoleBinding and ClusterRoleBinding objects do not have a built-in expiration field. You must use an external script or workflow tool to delete the binding on time.

Can I use a deny rule to block pod exec for one user?

No, native RBAC permissions are only additive and do not support deny rules. To block pod exec, you must remove the binding that grants that permission.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one specific namespace only. A ClusterRoleBinding grants permissions across all namespaces and cluster-scoped resources like nodes.

The query runs. The emails stay hidden.