How to Configure EKS Port Forward
You set up an eks port forward by granting Kubernetes RBAC role rules to a user. Then the user opens a local tunnel to a target pod through the cluster API server. Many teams start by handing out broad cluster roles to speed up daily work. Those wide roles let anyone reach internal apps and databases across every namespace. A safer approach uses narrow rules that limit each team to one namespace. How an eks port forward works with Kubernetes RBAC Kubernetes uses Role and ClusterRole objects t
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 an eks port forward by granting Kubernetes RBAC role rules to a user. Then the user opens a local tunnel to a target pod through the cluster API server. Many teams start by handing out broad cluster roles to speed up daily work. Those wide roles let anyone reach internal apps and databases across every namespace. A safer approach uses narrow rules that limit each team to one namespace.
How an eks port forward works with Kubernetes RBAC
Kubernetes uses Role and ClusterRole objects to hold sets of permission rules. These rules are purely additive, which means there are no deny rules in RBAC. A Role always sets permissions inside a single namespace. A ClusterRole works across the whole cluster and covers all namespaces at once. To grant these permissions to a person, you create a RoleBinding or a ClusterRoleBinding.
A RoleBinding grants permissions inside one specific namespace to a user or group. It can point to a Role in that same namespace or a shared ClusterRole. A ClusterRoleBinding grants access across the entire cluster at once. For port forwarding, Kubernetes checks a specific pod subresource in the API path. RBAC names resources and subresources using a slash, just like pod log paths.
When an engineer starts a tunnel, the API server checks their bound roles. The user needs permission to read the pod and create the port forward subresource. If the role check passes, the API server streams raw bytes to the pod. The engineer can then point local tools at a local port on their machine.
Why native roles are not enough for live traffic
Native Kubernetes RBAC is great at deciding who can open a tunnel. By using a RoleBinding instead of a ClusterRoleBinding, you isolate teams to one namespace. You stop developers from reaching pods in other namespaces by mistake. Still, Kubernetes RBAC cannot restrict create requests to specific subresource names. That means a user with port forward rights in a namespace can reach any pod there.
A bigger problem starts right after the API server approves the request. The port forward stream is just a raw network pipe to the target pod. Kubernetes logs show that a user opened a tunnel to a pod. The cluster logs do not show what happened inside that tunnel.
EKS Access Management + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Engineers often use port forwarding to reach private databases or internal admin apps. Once the tunnel is open, the cluster cannot inspect the queries or commands inside. If someone runs a bad query or reads private records, Kubernetes sees nothing. Native roles also cannot mask sensitive fields like emails, phone numbers, or card numbers. You know who opened the pipe, but you remain blind to the actual actions.
Scoping namespace roles for safer local tunnels
To reduce risk with native tools, start by auditing your existing ClusterRoleBindings. Remove broad cluster-wide bindings from regular developer groups right away. Create a dedicated Role inside each app namespace for day-to-day debugging tasks. Bind that Role to the specific team that owns the namespace using a RoleBinding.
Keep database pods and payment apps in their own separate namespaces. Do not grant port forward rules in those sensitive namespaces to general staff. When teams need to run queries or check data inside a pod, look beyond raw tunnels. You need a way to inspect individual commands and rewrite sensitive fields in results.
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 proxy, a sidecar for your Kubernetes API, inline on the API connection. On every kubectl or API call an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
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, or hold risky calls for approval. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs in memory. View the project on GitHub.
Frequently asked questions
Should I use a Role or a ClusterRole for port forwarding?
Use a Role or a ClusterRole paired with a namespace RoleBinding. This limits the user to pods inside one namespace instead of the whole cluster.
Can Kubernetes RBAC block a single pod from port forwarding in a namespace?
No, RBAC rules are purely additive and have no deny rules. Also, name limits on create actions apply to top-level resources, not subresources.
Do Kubernetes audit logs show the queries sent over a port forward tunnel?
No, the API server only logs that the subresource request started. It does not read or log the database queries or HTTP calls sent inside the tunnel.
Related guides
In this post