Access Pod in Kubernetes
To access pod in kubernetes, grant a user RBAC permissions for the pod and exec subresource. Then the engineer runs an interactive shell command through the Kubernetes API server. Most teams start by handing out broad cluster roles so developers can fix broken apps fast. Over time, these broad roles stay active and expose every container in the namespace to risk. How to access pod in kubernetes with native RBAC Kubernetes controls user actions through role-based rules enabled on the API serve
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.
To access pod in kubernetes, grant a user RBAC permissions for the pod and exec subresource. Then the engineer runs an interactive shell command through the Kubernetes API server. Most teams start by handing out broad cluster roles so developers can fix broken apps fast. Over time, these broad roles stay active and expose every container in the namespace to risk.
How to access pod in kubernetes with native RBAC
Kubernetes controls user actions through role-based rules enabled on the API server. These rules are purely additive, which means there are no deny rules in the system. You start by defining a Role for a single namespace or a ClusterRole for the whole cluster. Inside that role, you list the exact resources a person or group can touch.
Kubernetes splits pod data and pod actions into smaller parts called subresources. In RBAC rules, you write a subresource with a slash after the main resource name. For example, reading container output uses the pods and log subresource. Opening a shell inside a running container requires permission on the pods and exec subresource.
After you create the role, you must attach it to a user or team. A RoleBinding grants those permissions inside one specific namespace. A RoleBinding can point to a local Role or a shared ClusterRole. If a team needs the same permissions everywhere, you use a ClusterRoleBinding for the whole cluster.
Why native roles are not enough for production pods
Native Kubernetes RBAC is great at deciding who can reach a specific namespace or pod. It checks the user identity and confirms they hold the right role binding before opening a shell. This setup stops unauthorized users from entering namespaces they do not own.
Still, RBAC stops checking once the shell session starts inside the container. The API server knows that a user opened an exec session on a pod. It does not inspect the individual commands that the engineer types inside that shell. It also does not see the output that comes back to the user screen.
Just-in-Time Access + Kubernetes API Server Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Once inside a container, an engineer has the same local rights as the running app process. They can read local files, inspect memory, or view database keys stored in the pod. If the app handles user data, the engineer might pull emails, phone numbers, or card numbers. Native RBAC cannot rewrite matched fields in results or require approval for a single risky command.
Reducing risk when teams debug live containers
To keep clusters safe, teams should avoid giving out cluster-wide bindings for daily debugging work. Scope every Role and RoleBinding to the single namespace that the app team owns. Separate the roles that can read pod logs from the roles that can run exec sessions.
Most production bugs can be fixed by reading the pods and log subresource alone. Only grant exec permissions when an engineer must inspect the live container state directly. Even then, remember that native roles only guard the front door of the pod. Controlling what happens inside the shell requires inspection at the command level.
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 HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.
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. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.
Frequently asked questions
What RBAC rule lets a user read pod logs without shell access?
Grant read rules on the pods resource and the pods/log subresource in your Role. Leave out the pods/exec subresource so the user cannot open an interactive shell.
Can I add a deny rule to block one specific pod in a namespace?
No, Kubernetes RBAC permissions are purely additive and do not support deny rules. You must grant access only to the specific resource names the user needs.
Should I use a RoleBinding or a ClusterRoleBinding for app teams?
Use a RoleBinding for app teams because it limits their permissions to one namespace. A ClusterRoleBinding gives access across the entire cluster, which is too broad for app debugging.
Related guides
In this post