Kubectl Auth Can-i
You run the kubectl auth can i command to check if an identity can perform an action. It asks the Kubernetes API server if a specific verb and resource match your rules. Teams use this check when they set up role-based rules for developers and apps. Yet when roles are too broad, a simple yes hides major risks inside the cluster. How kubectl auth can i checks cluster permissions When you run kubectl auth can i, your client sends a review request to the API server. The server checks your active
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 run the kubectl auth can i command to check if an identity can perform an action. It asks the Kubernetes API server if a specific verb and resource match your rules. Teams use this check when they set up role-based rules for developers and apps. Yet when roles are too broad, a simple yes hides major risks inside the cluster.
How kubectl auth can i checks cluster permissions
When you run kubectl auth can i, your client sends a review request to the API server. The server checks your active identity against its role-based rule engine. 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 in the system.
A Role always sets permissions within one specific namespace. By contrast, a ClusterRole is not namespaced. It can cover cluster-scoped resources like nodes, non-resource endpoints, or namespaced resources across all namespaces. To grant these permissions to a user, you create a binding object.
A RoleBinding grants permissions within a single namespace. It can point to a Role in that same namespace or a shared ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. When you run a permission check, the API server reads all bindings that match your user or group.
If any matching rule allows the verb and resource, the server returns a yes answer. If no rule matches the request, the server returns a no answer. Admins can also combine the check with user impersonation to test what another account can do. This lets platform teams test a new Role before they hand credentials to a developer.
Checking subresources and namespace scopes
Kubernetes permissions go deeper than basic objects like pods or deployments. The RBAC system refers to resources by the exact name that appears in the API URL. Some APIs involve a subresource, such as reading a pod's logs or opening a shell session. In RBAC rules, you write the subresource with a slash, such as pods and log or pods and exec.
When teams run a permission check, they often test only top-level resources like pods. That check might return no for creating or deleting pods in a production namespace. Still, a separate rule might still allow the exec subresource on those exact same pods. You must check subresources directly to know if a user can run commands inside a container.
Network Location-Based Auth: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Scope also changes the result of your permission check. A user might have zero permissions at the cluster level. That same user might have full admin rights inside one staging namespace via a RoleBinding. Teams must always test permissions within the target namespace to get an accurate answer.
What native permission checks solve and what they miss
The native permission check is great for verifying static RBAC rules before a deployment runs. It helps platform engineers confirm that a service account or developer role has the right baseline scope. You can spot broad ClusterRoleBindings early and move users down to tighter namespace RoleBindings.
Still, this check only answers whether the API server will allow a session to start. It cannot inspect or control what happens inside that session once the request passes. For example, if a user has permission for the pods exec subresource, the check simply says yes. Once that shell opens, RBAC does not filter which shell commands the engineer runs inside the container.
The same gap exists when an engineer uses port forwarding to reach a database pod. The Kubernetes API server checks if the user can start the port forward stream. After the stream opens, Kubernetes cannot see the queries or rewrite sensitive fields like emails, phone numbers, or card numbers. Static RBAC decides who gets through the door, not what commands or data flow 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 runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.
First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. 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
Does kubectl auth can i change any cluster settings?
No, the command only sends a read-only check to the API server. It evaluates your current RBAC bindings and returns a simple yes or no response without changing any resources.
Why does a permission check say no when I have a RoleBinding?
A RoleBinding only grants permissions inside one specific namespace. If you run the check against a different namespace or at the cluster scope, the API server will return no.
Can I deny a specific action if a ClusterRole allows it?
No, Kubernetes RBAC permissions are purely additive and have no deny rules. To remove an allowed action, you must edit the Role or remove the binding that grants it.
Related guides
In this post