Record Kubectl Sessions for Kubernetes EKS
To record kubectl sessions for kubernetes eks, teams turn on API server audit logs. They also restrict pod subresource permissions through role-based access control. Most teams start by mapping cloud identities to broad cluster roles. When those roles stay too wide, any developer can open a shell inside live pods. Broad access makes it hard to track who ran specific commands during an incident. How to record kubectl sessions for kubernetes eks Kubernetes controls cluster actions through role-
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 record kubectl sessions for kubernetes eks, teams turn on API server audit logs. They also restrict pod subresource permissions through role-based access control. Most teams start by mapping cloud identities to broad cluster roles. When those roles stay too wide, any developer can open a shell inside live pods. Broad access makes it hard to track who ran specific commands during an incident.
How to record kubectl sessions for kubernetes eks
Kubernetes controls cluster actions through role-based access control on the API server. In this system, permissions only add access and never deny it. A Role sets permissions inside one single namespace. A ClusterRole sets permissions across the whole cluster and covers cluster-scoped resources like nodes. AClusterRole can also cover namespaced resources across every namespace at once.
To grant these permissions to users, admins create bindings. A RoleBinding gives a user or group permissions inside one specific namespace. That binding can reference a Role in the same namespace or a global ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once.
When an engineer runs a command or reads logs, Kubernetes uses subresources. The API server names these subresources with a slash, such as pods and exec. Admins must grant explicit permission for the exec subresource to allow shell access. They also grant permission for the log subresource so teams can read pod output. By scoping these rules tightly, teams limit who can start an interactive shell.
What native RBAC and audit logs leave open
Native roles and audit logs solve the first layer of cluster security. They decide who can log in and which namespaces a user can touch. When a developer starts an exec call, the API server logs that initial request. The audit log records the user identity, the target pod, and the initial command.
Still, a large operational gap keeps the session active once the connection starts. The API server switches the connection to a raw stream for standard input and output. Native audit logs do not capture the keystrokes or shell commands sent over that stream. They also do not log the text output that returns to the screen.
Kubernetes RBAC + EKS Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If an engineer opens a shell and edits a file, the audit log misses it. If they inspect sensitive data like emails or card numbers, no native log shows that action. Also, Kubernetes resource name rules for create actions only apply to top-level resources. Because they do not apply to subresources, scoping exec rules to single pods gets tricky. Native tools check who enters the door, not what commands run inside the room.
Why teams need command-level visibility in pods
Production incidents often require engineers to inspect live containers to fix broken apps. Blocking exec access entirely slows down recovery when a critical service fails. Yet giving out broad shell access without full command logs creates huge audit blind spots.
Security teams need to see every command run inside a container and its output. They also need ways to protect sensitive fields like phone numbers or national IDs in flight. Capturing the full interactive stream closes the gap left by standard API server logs. Teams get a clear trail of every action taken during a live debugging event.
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 sits inline beside the API server as a sidecar for your Kubernetes API. For every production API call an agent or human sends, hoop.dev decides whether to pass, mask, block, or escalate it for review alongside RBAC.
With hoop.dev Kubernetes controls, guardrails allow listing Secret names while refusing reads of Secret data before execution, and 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
Do native Kubernetes audit logs capture interactive shell commands?
No, native audit logs only record the initial request to open the pod exec subresource. Once the interactive shell opens, the API server does not log the commands typed inside.
How does Kubernetes control who can run kubectl exec?
Admins use a Role or ClusterRole that includes rules for the pods exec subresource. They then link that role to users with a RoleBinding or ClusterRoleBinding.
Can Kubernetes RBAC deny exec access to one specific pod?
No, Kubernetes permissions are purely additive and have no deny rules. Admins must grant narrow permissions from the start instead of trying to block single pods later.
Related guides
In this post