GCP GKE

Published
Length
3 min read

Luis Felipe Dias

All posts

You manage gcp gke access by pairing cloud identity accounts with native Kubernetes role rules. You define roles for each namespace and bind them to specific team groups. Many teams start by giving developers broad cluster roles to speed up daily work. Broad roles let users read secret keys or run shell commands across all running pods. A tight setup limits each user to the exact namespace and objects they need. How gcp gke role permissions work in practice Kubernetes role control uses four m

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 manage gcp gke access by pairing cloud identity accounts with native Kubernetes role rules. You define roles for each namespace and bind them to specific team groups. Many teams start by giving developers broad cluster roles to speed up daily work. Broad roles let users read secret keys or run shell commands across all running pods. A tight setup limits each user to the exact namespace and objects they need.

How gcp gke role permissions work in practice

Kubernetes role control uses four main objects to manage what users can do. These objects are Role, ClusterRole, RoleBinding, and ClusterRoleBinding. Every rule in this system is additive, which means there are no deny rules. You start with zero access and add rules for each needed action.

A Role sets permissions inside one specific namespace. A ClusterRole is not tied to a single namespace. It can cover cluster-wide objects like nodes or apply to resources across all namespaces. To give these rules to a user, you create a binding.

A RoleBinding grants permissions inside one namespace. You can point a RoleBinding to a local Role or a shared ClusterRole. Pointing a RoleBinding to a ClusterRole lets you reuse common rules across many teams. A ClusterRoleBinding grants permissions across the whole cluster at once. You should reserve ClusterRoleBinding objects for platform admins who manage the whole cluster.

Kubernetes also uses subresources for actions like reading pod logs or running container commands. In role rules, you write a subresource with a slash, such as pods/log or pods/exec. You must grant these subresources on their own if a user needs them.

What native roles solve and what they leave open

Native roles and bindings do a good job of controlling who enters the cluster. They let you separate namespaces by team and block users from changing other apps. You can allow a developer to view pods in one namespace while blocking delete actions. This keeps your cluster layout clean and stops most accidental changes to cluster state.

Still, native role checks stop once the API server approves the initial request. When a user gets pods/exec permission, the API server opens a live shell stream. Kubernetes checks that the user can start the exec call, not what happens next. Inside that shell, the user runs as the container process user.

GCP IAM Bindings + GKE Workload Identity: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

The native role system does not inspect individual commands typed inside that open session. It also does not filter or rewrite sensitive data printed to the terminal screen. If a pod holds database keys or customer emails, a shell user can read them. The same gap exists when users read pod logs through the pods/log subresource. If an app prints card numbers or phone numbers to logs, anyone with log access sees them.

How to tighten daily cluster access workflows

To reduce risk, start by removing ClusterRoleBinding grants from regular developer accounts. Map each team to their own namespace using a standard RoleBinding instead. Split read-only viewing roles from roles that allow pod shell sessions.

Keep pods/exec out of default developer roles whenever you can. Most daily debugging only requires checking pod status events and reading app logs. When someone needs to run a command inside a pod, treat that as a special task. You also need a way to watch active commands and protect sensitive output in flight.

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

Can I write a deny rule in Kubernetes RBAC to block one specific pod?

No, Kubernetes role permissions are purely additive and do not support deny rules. To block access, you must remove the broad grant and add back smaller rules.

What is the difference between a RoleBinding and a ClusterRoleBinding in gcp gke?

A RoleBinding grants permissions inside one single namespace. A ClusterRoleBinding grants those permissions across every namespace and cluster resource at the same time.

How do I let developers view pod logs without giving them shell access?

Create a Role that grants get and list on pods and the pods/log subresource. Leave the pods/exec subresource out of the rule list so users cannot open shells.

The query runs. The emails stay hidden.