Kubernetes Structured Authentication

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up kubernetes structured authentication by linking external token providers to the API server. This setup lets teams manage multiple identity sources with one file instead of single startup settings. Platform teams often map broad identity groups to wide cluster roles during setup. Overly broad roles give engineers too much power across all namespaces and pods. How kubernetes structured authentication and native roles work The API server checks incoming requests against external ident

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 kubernetes structured authentication by linking external token providers to the API server. This setup lets teams manage multiple identity sources with one file instead of single startup settings. Platform teams often map broad identity groups to wide cluster roles during setup. Overly broad roles give engineers too much power across all namespaces and pods.

How kubernetes structured authentication and native roles work

The API server checks incoming requests against external identity providers using token validation rules. Once the server confirms the user identity, role-based access control takes over. In Kubernetes, a Role or ClusterRole holds rules that represent a set of permissions. These permissions are purely additive, which means there are no deny rules.

A Role always sets permissions within one single namespace. A ClusterRole is not namespaced and can cover cluster-scoped resources like nodes. It can also cover non-resource endpoints or namespaced resources across all namespaces. Teams then connect users or groups to these roles using bindings.

A RoleBinding grants permissions inside one specific namespace. It can point to a Role in that namespace or a shared ClusterRole. By contrast, a ClusterRoleBinding grants permissions across the entire cluster at once. All of these objects live in the native RBAC API group on the server.

How subresources work in Kubernetes access control

Kubernetes RBAC refers to resources by the exact name in the API URL. Some API calls target a subresource, such as reading logs from a running pod. In RBAC rules, the subresource name uses a slash after the main resource. This pattern applies when teams read pod logs or run commands inside containers.

Admins often try to lock down subresources to specific named pods. Still, name restrictions on create calls apply only to top-level resources, not subresources. If a user can run commands in a namespace, they can target any pod there. Because rules only add permissions, you cannot write a rule to block one pod.

This design forces platform teams into a hard choice during role setup. They must either build many tiny namespaces or grant wide access per namespace. Most teams pick wider roles so engineers can fix broken apps during incidents. That choice makes login easy, but it creates risk inside the cluster.

Kubernetes RBAC + Multi-Factor Authentication (MFA): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native cluster setups solve and what they miss

Structured login and native roles solve the problem of who can enter the cluster. They let you connect corporate groups to cluster namespaces without sharing static keys. You can revoke a user in your identity provider to block future API calls. This setup gives you a clean way to manage user entry at scale.

Still, native roles only check the start of an API request. Once a binding allows an interactive shell inside a pod, Kubernetes steps back. The API server does not inspect the commands an engineer runs inside that shell. It also cannot rewrite sensitive data like emails or card numbers in command output.

Native audit logs record that a user opened a shell session on a pod. They do not record the actual shell commands or the output returned to the screen. Similarly, if a user can read secrets, the server returns the full raw values. Teams need deeper controls to govern what happens inside active cluster sessions.

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 add a deny rule to block one specific pod in Kubernetes RBAC?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To restrict access, you must grant smaller roles or split workloads into separate namespaces.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding grants permissions inside one specific namespace only. A ClusterRoleBinding grants permissions across every namespace and cluster-scoped resource in the cluster.

Does Kubernetes structured login inspect commands run inside a pod shell?

No, structured login and RBAC only check if the user can start the shell request. They do not inspect or filter the commands run inside that interactive session.

The query runs. The emails stay hidden.