Kubernetes OIDC Provider
You set up a kubernetes oidc provider by pointing the API server to your identity system. The API server checks signed tokens from that system and maps users to cluster roles. Teams often start by linking entire directory groups to broad cluster admin roles for speed. When roles are too broad, any user in that group can alter workloads across namespaces. Over time, those shared roles give engineers far more power than their daily tasks require. How a kubernetes oidc provider works with RBAC I
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 a kubernetes oidc provider by pointing the API server to your identity system. The API server checks signed tokens from that system and maps users to cluster roles. Teams often start by linking entire directory groups to broad cluster admin roles for speed. When roles are too broad, any user in that group can alter workloads across namespaces. Over time, those shared roles give engineers far more power than their daily tasks require.
How a kubernetes oidc provider works with RBAC
In Kubernetes, the API server does not store a native database of human user accounts. Instead, it trusts an external identity system that follows the OpenID Connect standard. When an engineer logs in, the identity system issues a signed token with user claims. The engineer sends this token to the API server with each command. The API server checks the signature and reads the user name and group claims.
Once the API server knows who the user is, role-based access control takes over. Kubernetes RBAC uses Roles and ClusterRoles to hold sets of permission rules. All rules in this system are purely additive, which means there are no deny rules. A Role sets permissions inside one single namespace. A ClusterRole is not tied to one namespace and can cover nodes or all namespaces.
To grant these rules to your OIDC users, you create a RoleBinding or a ClusterRoleBinding. A RoleBinding grants permissions inside one namespace and can reference a Role or a ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. You map the user or group claim from the OIDC token directly into that binding.
How subresources work in Kubernetes RBAC
Kubernetes RBAC refers to resources by the exact name shown in the API URL. Some APIs include a subresource, such as reading a pod log or running a command. In RBAC rules, you write the subresource with a slash after the main resource name. For example, rules for pod logs or pod execution use this slash format.
Teams often try to limit which specific pods an engineer can reach with subresource rules. Still, the resource name filter on create actions applies only to top-level resources. It does not apply to subresources when the request is a create action. If a role allows pod execution in a namespace, the user can reach every pod there. Because RBAC is purely additive, you cannot add a separate deny rule to block one pod.
Kubernetes RBAC + K8s OIDC Authentication: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native OIDC and RBAC leave open
Linking a kubernetes oidc provider to RBAC solves the problem of who can log in. You no longer need to share static client certificates or long-lived service account tokens with humans. When a person leaves the team, you disable their account in one central identity directory. That change stops their ability to get new tokens for the cluster.
Still, native OIDC and RBAC only check permissions at the start of an API request. Once RBAC allows a pod execution request, the API server opens an interactive stream. Native RBAC does not inspect the shell commands that the engineer runs inside that container. It also cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs in output. Teams that need command checks or data masking in flight must look beyond native RBAC.
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 runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.
With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. 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
Can I write a deny rule in Kubernetes RBAC for OIDC users?
No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To restrict an OIDC user, you must grant a smaller Role and remove broad bindings.
What is the difference between a RoleBinding and a ClusterRoleBinding?
A RoleBinding grants permissions inside one specific namespace, even when it points to a ClusterRole. A ClusterRoleBinding grants the permissions from a ClusterRole across the entire cluster and all namespaces.
Does OIDC control what commands a user runs inside a pod?
No, the OIDC setup only verifies user identity for the Kubernetes API server. Once RBAC allows pod execution, native cluster controls do not filter shell commands inside the container.
Related guides
In this post