K8s Internaltrafficpolicy
You set up k8s internaltrafficpolicy to keep service traffic on the same node. This setting tells Kubernetes to route requests only to local pods on that node. Platform teams use this rule to cut network hops and lower data costs. Still, teams often grant broad cluster roles so engineers can edit these service rules. Broad roles let users change network paths or run commands in any pod. How k8s internaltrafficpolicy and role rules work When a pod sends traffic to a service, Kubernetes picks a
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 k8s internaltrafficpolicy to keep service traffic on the same node. This setting tells Kubernetes to route requests only to local pods on that node. Platform teams use this rule to cut network hops and lower data costs. Still, teams often grant broad cluster roles so engineers can edit these service rules. Broad roles let users change network paths or run commands in any pod.
How k8s internaltrafficpolicy and role rules work
When a pod sends traffic to a service, Kubernetes picks a backing pod. By default, the cluster can pick a pod on any node. With k8s internaltrafficpolicy set for local routing, only pods on the same node get traffic. If no local pod is ready, the service drops the network request.
To change this service setting, an engineer needs permission in Kubernetes RBAC. Kubernetes RBAC uses Roles and ClusterRoles to hold sets of permission rules. These rules are additive, which means there are no deny rules at all. A Role sets permissions inside one namespace for your team. A ClusterRole can cover resources across all namespaces or cover cluster-wide nodes. You attach these rules to users with a RoleBinding or a ClusterRoleBinding.
Engineers also want to test if local traffic routing works as planned. To do this, they often ask for access to pod logs or pod shells. In Kubernetes RBAC, these features are subresources under the main pod resource. An admin must grant access to the log subresource or the exec subresource. If an admin grants a ClusterRoleBinding for these, the user can reach every namespace.
What native roles solve and what they miss
Native Kubernetes roles control who can edit service objects in the API server. You can limit a user to one namespace with a standard RoleBinding. This stops an engineer from changing traffic rules for other teams.
K8s Namespace Isolation: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, native RBAC only checks permissions when a user starts an API request. Once a user gets exec access to test network routing, RBAC steps back. It does not inspect the shell commands that the user runs inside the pod. A user testing local service routing can read local files or query a database. They can also see sensitive values like emails, phone numbers, or card numbers. Also, restricting subresources by specific resource names on create actions does not work. This leaves a gap between who can log in and what commands they run.
Scoping service and pod permissions
Start by moving away from cluster-wide bindings for daily network tasks. Give each team a Role and RoleBinding inside their own namespace. Grant edit rights only on service objects if they just change routing rules. Keep pod exec permissions out of standard developer roles whenever you can. When engineers must debug live pods, add controls that watch commands in flight. You should also mask sensitive data like national IDs or emails in command output.
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 HTTP proxy, a sidecar for your Kubernetes API. The kubectl client changes only the server address it talks to while RBAC stays in place.
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. On the way back, hoop.dev data masking walks JSON responses by key and masks matched values in Secrets, ConfigMaps, and pod logs. Every request and verdict is logged without storing bearer tokens. View the project on GitHub.
Frequently asked questions
What happens when no local pod is available for internal traffic?
Kubernetes drops the traffic if no pod is ready on that same node. It will not send the request to a pod on another node.
Can I use a deny rule in Kubernetes RBAC to block service edits?
No, Kubernetes RBAC rules are additive only and do not support deny rules. You must remove the permission from the Role or RoleBinding to block edits.
How should we grant permissions to edit service traffic policies?
Create a Role in one namespace that allows updates on service resources only. Bind that Role to your team with a namespaced RoleBinding instead of a ClusterRoleBinding.
Related guides
In this post