Kubernetes Egress Proxy

Published
Length
3 min read

Luis Felipe Dias

All posts

A kubernetes egress proxy routes outbound traffic from your pods through a controlled network point. You set up this pattern by pairing network routing rules with native cluster permissions. Platform teams use this setup to restrict which external services an app can reach. Still, broad cluster roles often let users bypass these limits during debug sessions. When a user runs commands inside a pod, their traffic inherits the pod network path. How a kubernetes egress proxy works with cluster rol

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.

A kubernetes egress proxy routes outbound traffic from your pods through a controlled network point. You set up this pattern by pairing network routing rules with native cluster permissions. Platform teams use this setup to restrict which external services an app can reach. Still, broad cluster roles often let users bypass these limits during debug sessions. When a user runs commands inside a pod, their traffic inherits the pod network path.

How a kubernetes egress proxy works with cluster roles

In a standard cluster, pods send traffic straight to outside networks if routing allows it. Teams deploy a kubernetes egress proxy to funnel all outbound calls through one checkpoint. This checkpoint checks destination hosts and logs network packets leaving the cluster. To keep this setup safe, you must lock down who can change pod settings.

Native access control uses a Role or a ClusterRole to hold permission rules. In Kubernetes, permissions are additive, and there are no deny rules. A Role sets permissions inside one namespace. A ClusterRole is not namespaced and can cover resources across all namespaces. It can also cover cluster-scoped resources like nodes. You then attach these rules to users or service accounts.

A RoleBinding grants permissions inside one namespace by referencing a Role or a ClusterRole. A ClusterRoleBinding grants access across the entire cluster. When a team sets up outbound traffic routing, they use these bindings to restrict changes. Only trusted operators should edit the pods that route outbound traffic. If a binding is too wide, any developer could deploy a pod that skips the outbound path.

Where native permissions and network routing fall short

Network routing controls where packets go, while RBAC controls who can call the API server. RBAC refers to resources by the exact name that appears in the API URL. Some APIs include a subresource, such as a pod log or an exec action. In RBAC rules, you write the subresource with a slash, like pods/log or pods/exec.

Here lies a common gap for security teams. An engineer often needs to run commands inside a running pod to fix a bug. You grant them access to the pods/exec subresource through a RoleBinding. Once that engineer starts a shell inside the pod, RBAC steps out of the way. The API server checks who can start the session, not what happens next.

Database Proxy (ProxySQL, PgBouncer) + Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Inside the pod, the engineer can use the pod outbound network allowance. If the pod can reach an external database, the engineer can reach it too. The outbound network checkpoint only sees traffic coming from an allowed pod IP. It cannot tell if a request came from app code or a human shell. Also, the network layer does not inspect individual queries or mask sensitive fields like emails, phone numbers, card numbers, or national IDs.

Securing interactive pod access and outbound calls

To reduce risk, teams should separate app network needs from human debug workflows. First, keep RoleBindings narrow so users only touch the specific namespaces they own. Avoid using a ClusterRoleBinding for day-to-day developer tasks. Second, audit every role that grants access to the pods/exec subresource.

Even with tight roles, native controls only decide who starts a session. They do not inspect individual commands or database queries in flight. Teams need a way to govern what people and scripts run after login succeeds.

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 runs beside the API server as a sidecar for your Kubernetes API and checks every request and response alongside RBAC.

With hoop.dev Kubernetes controls, guardrails can allow listing Secret names while refusing reads of Secret data before execution. 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

What does an outbound proxy do in a cluster?

It acts as a single exit point for traffic leaving your cluster pods. Teams use it to control and log which outside endpoints their apps can call.

Can Kubernetes RBAC block specific outbound network calls?

No, RBAC only controls requests made to the Kubernetes API server. It uses additive rules in a Role or ClusterRole to permit API actions, not network packets.

Why does pods/exec matter for outbound traffic security?

The pods/exec subresource lets a user run commands inside a pod. From inside that pod, the user can send traffic through any external route the pod is allowed to use.

The query runs. The emails stay hidden.