How to Configure GKE Exec Into Pod

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gke exec into pod access by granting RBAC rules for the pod exec subresource. You bind a Role or ClusterRole to a user or group in your cluster. Many teams take a shortcut and assign broad admin roles during an incident. Broad roles let users read secrets, delete workloads, or change cluster state across namespaces. Scoping permissions down to the exact namespace and resource prevents accidental changes. How gke exec into pod permissions work Kubernetes controls cluster actions thr

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 gke exec into pod access by granting RBAC rules for the pod exec subresource. You bind a Role or ClusterRole to a user or group in your cluster. Many teams take a shortcut and assign broad admin roles during an incident. Broad roles let users read secrets, delete workloads, or change cluster state across namespaces. Scoping permissions down to the exact namespace and resource prevents accidental changes.

How gke exec into pod permissions work

Kubernetes controls cluster actions through Role-Based Access Control on the API server. In RBAC, rules are always additive, and there are no deny rules. You start with zero access and add rules for each action you need. A Role sets rules inside one single namespace. A ClusterRole sets rules across the entire cluster and all namespaces.

To let a developer open a shell, you must grant access to a subresource. Kubernetes RBAC names resources the exact same way they appear in the API URL. A pod shell uses the exec subresource, written with a slash after the pod resource. Your Role needs rules that allow viewing pods and creating the pod exec subresource.

After you write the Role, you attach it to a user with a RoleBinding. A RoleBinding grants those rules inside one specific namespace. It can point to a local Role or a shared ClusterRole. If you use a ClusterRoleBinding instead, the user gets exec rights in every namespace. Most teams prefer a RoleBinding so developers stay inside their own app namespace. You can also list specific resource names in the rule to restrict access further.

What native RBAC solves and what it misses

Native Kubernetes RBAC is great at deciding who can start a pod session. It checks the user identity and blocks unauthorized calls at the API server. You can limit a team to one namespace or even specific pod names. This stops a developer from opening a shell in another team's workload.

Still, native RBAC stops checking once the shell session starts. It decides who gets in, not what commands run inside the container. Once inside, the user acts with the Linux user rights of that container. If the container runs as root, the user has root rights inside the pod. They can read local files, inspect memory, or dump app keys from the environment.

K8s Pod Security Standards + GKE Workload Identity: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Native cluster logs also miss the details of an interactive shell session. The API server records that a user started an exec call on a pod. It does not capture the commands typed or the output returned inside that shell. When an incident happens, auditors see who entered the pod, not what they did. If a command prints customer emails or card numbers, nothing masks that output. Native RBAC also keeps permissions active until an admin removes the binding.

Scoping pod shell access for daily operations

To keep clusters safe, separate routine debugging from interactive shell sessions. Grant pod log subresource permissions for daily checks so engineers can read app output. Keep pod exec subresource rules out of default developer roles. When someone needs a shell, bind the role only to the single namespace required. Review your bindings often to remove lingering access after an incident ends.

Add request guardrails and response masking beside Kubernetes

Cluster roles and service accounts govern who reaches the Kubernetes API. Still, a broad role or agent can delete workloads or print sensitive values from ConfigMaps and logs. In practice, hoop.dev sits inline beside the API server as a sidecar for your Kubernetes API. For every production API call an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review alongside RBAC.

With hoop.dev Kubernetes controls, guardrails allow listing Secret names while refusing reads of Secret data before execution, and data masking redacts matched keys in returned JSON responses and log streams in memory. Furthermore, hoop.dev holds SOC 2 Type II and is MIT licensed on GitHub.

Frequently asked questions

What RBAC rule allows a user to open a pod shell?

The user needs a Role or ClusterRole that covers the pod exec subresource. You must bind that role to the user with a RoleBinding or ClusterRoleBinding.

Should I use a RoleBinding or a ClusterRoleBinding for pod exec?

Use a RoleBinding for almost all developer and app team workflows. A RoleBinding limits shell access to one namespace, while a ClusterRoleBinding opens every namespace.

Does Kubernetes RBAC restrict which commands run inside the pod?

No, Kubernetes RBAC only checks if the user can start the exec session. Once the shell opens, the container's own operating system permissions control what commands can run.

The query runs. The emails stay hidden.