Google Kubernetes Service

Published
Length
3 min read

Luis Felipe Dias

All posts

You manage a google kubernetes service cluster by pairing cloud identities with native role rules. You define roles for each namespace and bind them to user groups or service accounts. Most teams start by mapping broad cloud groups to cluster roles so devs can check apps. When these roles are too wide, any user can run commands or read secret keys across namespaces. How native roles work in a google kubernetes service cluster The native permission system uses four main objects to control what

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 a google kubernetes service cluster by pairing cloud identities with native role rules. You define roles for each namespace and bind them to user groups or service accounts. Most teams start by mapping broad cloud groups to cluster roles so devs can check apps. When these roles are too wide, any user can run commands or read secret keys across namespaces.

How native roles work in a google kubernetes service cluster

The native permission system uses four main objects to control what users can do. A Role sets rules inside one namespace, while a ClusterRole covers the whole cluster. ClusterRoles can manage cluster items like nodes or apply rules across every namespace at once. All permission rules in this system are additive, which means there are no deny rules.

To give a user these permissions, you create a binding object in the cluster. A RoleBinding grants permissions inside one namespace and can point to a Role or ClusterRole. A ClusterRoleBinding grants permissions across the whole cluster for all namespaces and nodes. The API server checks these bindings each time a user sends a request.

The API also uses subresources for actions like reading pod logs or opening a pod shell. In role rules, you write the main resource and the subresource with a slash between them. You must grant permissions on the pod exec subresource before a user can open a shell. You must also grant permissions on the pod log subresource so a user can read logs.

What native roles solve and what they leave open

Native roles and bindings do a good job of deciding who can call each API endpoint. You can limit a dev team to one namespace and block them from changing cluster nodes. You can also separate read roles from write roles so most users only view pod states. This setup stops random users from deleting workloads or reading keys in other namespaces.

Still, native role checks stop the moment the API server approves the initial request. Once a user has permission for the pod exec subresource, they can open a live shell. Native role rules do not check the individual shell commands that run inside that pod. They also do not mask sensitive data like emails, phone numbers, or card numbers in output.

Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts and long-lived local config files create another gap for security teams. When devs store cluster keys on their laptops, teams must rotate those keys by hand. Native audit logs record that a shell session started, but not the commands typed inside it. Teams need a way to check every command in flight and redact sensitive output fields.

How to tighten pod shell and log permissions

Start by removing cluster-wide bindings from human users and daily dev groups. Give each team a RoleBinding that applies only to their own app namespace. Keep the pod log subresource in standard read roles, but pull the pod exec subresource out. Only grant pod shell permissions when a user needs to fix a live issue.

Next, audit every ClusterRoleBinding to find accounts that hold full admin rights across namespaces. Replace broad bindings with namespace RoleBindings that point to a shared read-only ClusterRole. This lets you keep one common set of read rules while limiting where each team works. Review these bindings often to make sure old accounts do not keep active permissions.

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

Can I write a deny rule in native cluster roles?

No, native role permissions are only additive and do not support deny rules. You must start with zero permissions and add only the specific rules a user needs.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one single namespace, even if it references a ClusterRole. A ClusterRoleBinding grants those permissions across all namespaces and cluster resources at once.

Do native role rules check commands inside a pod shell?

No, native rules only check if the user can call the pod exec subresource API. Once the shell opens, the cluster does not inspect or filter the commands that run inside.

The query runs. The emails stay hidden.