How to Configure GKE Pod Security

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up gke pod security by defining Kubernetes roles and pod admission rules. These rules control how pods run and which users can reach them. Most teams start by assigning broad cluster roles to speed up daily work. Overly broad roles let too many users open interactive shells inside running containers. That wide access turns a single compromised account into a full cluster incident. How native gke pod security works in practice Kubernetes manages user access through role-based access co

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 pod security by defining Kubernetes roles and pod admission rules. These rules control how pods run and which users can reach them. Most teams start by assigning broad cluster roles to speed up daily work. Overly broad roles let too many users open interactive shells inside running containers. That wide access turns a single compromised account into a full cluster incident.

How native gke pod security works in practice

Kubernetes manages user access through role-based access control on the API server. A Role holds a list of rules that grant permissions inside one namespace. A ClusterRole holds rules that apply across all namespaces or to cluster-wide nodes. Permissions in this system are purely additive and never include deny rules. You start with zero access and add rules for each needed action.

To give a user those permissions, you create a binding object. A RoleBinding grants the rules to a user within one specific namespace. A RoleBinding can link to a local Role or a shared ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. Teams use a RoleBinding to keep developer permissions locked to one project namespace.

Pod security also depends on controlling subresources in the API URL. Kubernetes treats actions like reading pod logs or running shell commands as subresources. In role rules, you write these subresources with a slash after the resource name. You must grant specific permissions for the log subresource or the exec subresource. If you leave out the exec subresource, users cannot open shells in pods.

What native roles solve and where they fall short

Native roles and bindings do a good job of sorting users by team. You can limit developers to viewing pods and reading logs in staging namespaces. You can also block most users from creating privileged pods in production. This setup decides who can log in and start an action on a pod.

Still, native access rules stop checking once a user starts an exec session. When an engineer gets exec permissions to fix a bug, the API server steps back. Kubernetes does not check individual shell commands while the session runs in flight. A user with exec access can read local files or dump memory variables.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Resource name limits in role rules also have built-in boundaries on subresources. You cannot restrict a create action on a subresource by specific resource names. That makes it hard to grant shell access to just one single pod. Teams often grant exec access to an entire namespace during an outage. Also, if a command prints sensitive customer data like emails or card numbers, Kubernetes returns it raw. Native roles cannot rewrite matched fields in results or ask for per-command approval.

Steps to tighten pod access across namespaces

Start by auditing every ClusterRoleBinding in your cluster to find wide permissions. Replace cluster-wide bindings with namespace RoleBindings wherever a team works on one app. Separate daily read roles from break-glass roles that allow pod exec sessions. Make sure default developer roles only include the log subresource for debugging.

Next, review every role that grants access to the pod exec subresource. Remove exec permissions from standard accounts and keep them for emergencies only. When engineers need to inspect a live container, require a clear approval workflow. Pair your native role setup with runtime controls that inspect commands in flight.

Govern kubectl and API calls in flight

Identity providers and Kubernetes RBAC decide who logs into a cluster. They cannot redact keys inside returned JSON objects or hold a risky delete call for review. By design, hoop.dev sits inline as an open-source proxy, a sidecar for your Kubernetes API, without replacing RBAC. On every production call from an engineer or AI agent, hoop.dev decides to pass, mask, block, or hold it for human approval.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run or hold risky deletes for review. Next, hoop.dev data masking rewrites sensitive keys in returned Secret, ConfigMap, and log responses in memory, and writes each decision to the audit trail. Explore the repo on GitHub.

Frequently asked questions

Can I use a deny rule in Kubernetes RBAC to block pod exec?

No, Kubernetes RBAC permissions are purely additive and have no deny rules. To block pod exec, you must remove the exec subresource from the user's assigned roles.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions to users inside one single namespace. A ClusterRoleBinding grants permissions across all namespaces and cluster-scoped resources at the same time.

How does Kubernetes control access to pod logs and shell sessions?

Kubernetes uses API subresources written with a slash, like the log and exec subresources. You must add these exact subresources to a Role or ClusterRole to allow access.

The query runs. The emails stay hidden.