How to Configure AKS Exec Into Pod
To set up an aks exec into pod workflow, grant Kubernetes RBAC permissions for the pod exec subresource. You bind a Role or ClusterRole to a user or group so they can run commands inside containers. Many teams start by giving developers broad cluster roles during an outage. Overly broad roles let users run commands in every container and read sensitive keys across the whole cluster. How native aks exec into pod permissions work Kubernetes controls container command execution through its built
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.
To set up an aks exec into pod workflow, grant Kubernetes RBAC permissions for the pod exec subresource. You bind a Role or ClusterRole to a user or group so they can run commands inside containers. Many teams start by giving developers broad cluster roles during an outage. Overly broad roles let users run commands in every container and read sensitive keys across the whole cluster.
How native aks exec into pod permissions work
Kubernetes controls container command execution through its built-in role-based access control system. Permissions in this system are purely additive, which means there are no deny rules. You start by choosing between a namespaced Role and a cluster-wide ClusterRole. A Role sets permissions inside one specific namespace. A ClusterRole can cover resources across all namespaces in your cluster.
In Kubernetes RBAC, each resource name matches the path in the API URL. Container command execution uses a subresource under the main pod object. RBAC rules write this subresource by joining the parent resource and subresource with a slash. An admin must grant access to both the base pod resource and the exec subresource. Without the subresource rule, the API server blocks the command request right away.
After you define the role rules, you link them to users with a binding. A RoleBinding grants permissions inside one namespace. It can point to a Role in that same namespace or a shared ClusterRole. If a team needs to run commands in every namespace, an admin uses a ClusterRoleBinding instead. This setup gives you a clear way to divide permissions by team and namespace.
What native RBAC solves and what it leaves open
Native Kubernetes RBAC solves the problem of who can start a container session. It lets platform teams scope permissions down to a single namespace or specific named pods. You can stop developers from entering containers that belong to other teams. You can also separate log reading permissions from command execution permissions by using different subresources.
Still, native RBAC only checks permissions at the moment the session starts. Once the API server allows the request, RBAC does not inspect what happens inside the shell. It cannot tell the difference between a safe status check and a destructive command. A user with exec rights can read local files, inspect memory, or change running processes.
Standard Kubernetes audit logs also struggle with interactive shell sessions. The API server records that a user opened an exec subresource session on a specific pod. It does not record the individual shell commands typed inside that open stream. Nor does it mask sensitive data like emails, phone numbers, card numbers, or national IDs printed to the screen. Teams need deeper controls to review commands and protect sensitive outputs during live container sessions.
K8s Pod Security Standards + AKS Managed Identity: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Scoping pod exec roles for safer daily operations
Before adding runtime controls, teams should tighten their baseline Kubernetes RBAC roles. Avoid using ClusterRoleBindings for human users who only manage one app. Instead, create a RoleBinding in the specific namespace where that app runs. This simple step limits the blast radius if a developer account gets compromised.
You should also separate read-only debugging roles from active shell execution roles. Most daily checks only require reading pod status and viewing container logs. Grant the log subresource for normal work and keep the exec subresource in a separate role. Teams can then bind the exec role only when deeper container checks are necessary.
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
Why can a user view pods but still fail to run an aks exec into pod command?
Viewing pods only requires permissions on the base pod resource. Running commands inside a container requires explicit permission on the pod exec subresource in the RBAC role.
Should I use a RoleBinding or a ClusterRoleBinding for pod exec access?
Use a RoleBinding whenever possible to keep container shell access inside a single namespace. A ClusterRoleBinding grants access across every namespace, which gives users far too much reach.
Does Kubernetes RBAC let me write a rule to deny pod exec in one namespace?
No, Kubernetes RBAC permissions are purely additive and do not support deny rules. To restrict access, remove the wide binding and grant permissions only in the allowed namespaces.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post