Kubernetes Behind Proxy

Published
Length
3 min read

Luis Felipe Dias

All posts

To run kubernetes behind proxy setups, you place the API server in a private network. Then you route team requests through a controlled entry point with strict role rules. Many teams start by giving developers wide cluster roles to speed up daily work. When roles are too broad, one bad command can break shared apps across namespaces. A strong setup combines network routing with tight role bindings. How native RBAC works for kubernetes behind proxy Once traffic reaches the API server, native R

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 run kubernetes behind proxy setups, you place the API server in a private network. Then you route team requests through a controlled entry point with strict role rules. Many teams start by giving developers wide cluster roles to speed up daily work. When roles are too broad, one bad command can break shared apps across namespaces. A strong setup combines network routing with tight role bindings.

How native RBAC works for kubernetes behind proxy

Once traffic reaches the API server, native RBAC checks every request. In Kubernetes, a Role or ClusterRole holds a list of permission rules. These rules are additive, which means there are no deny rules at all. You start with zero access and add only the rules each team needs.

A Role sets permissions inside one single namespace. In contrast, a ClusterRole is not tied to one single namespace. It can cover cluster-wide items like nodes or resources across all namespaces. It can also cover endpoints that do not map to standard cluster resources.

To give these permissions to a user, you create a binding. A RoleBinding grants permissions inside one namespace by linking to a Role or ClusterRole. A ClusterRoleBinding grants permissions across the entire cluster at once. You should use a RoleBinding when a team only runs apps in one namespace. If you reuse a ClusterRole inside a RoleBinding, the user only gets local rights.

Subresource rules for pod logs and container shells

RBAC names resources using the exact words found in the API URL. Some API calls target a subresource, such as reading logs from a running pod. In RBAC rules, you write the subresource using a slash after the main resource. For example, you grant log reading rights by naming the pods and log subresource.

Opening a shell inside a container also uses a subresource for pod execution. Many teams give out pod execution rights so engineers can fix live bugs. If you grant this rule across a whole namespace, users can enter any pod. You must scope these subresource rules with great care.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and the gap they leave

Native roles and bindings do a great job of controlling initial entry. The API server checks who is calling and which resource they want to touch. If a user lacks the right binding, the API server blocks the call right away. This stops unauthorized users from reading pod logs or opening container shells.

Still, native RBAC only checks the request when the session starts. Once a user opens a container shell, RBAC does not inspect the commands inside. It cannot stop a destructive shell script or rewrite sensitive fields like emails in output. It also does not require a peer to approve a single risky command in flight. Teams still need a way to govern live commands and mask phone numbers or card numbers.

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

Can I write a deny rule in Kubernetes RBAC?

No, Kubernetes RBAC rules are only additive and do not support deny rules. To limit a user, you must remove the broad binding and grant a smaller Role.

What is the difference between a RoleBinding and a ClusterRoleBinding?

A RoleBinding applies permissions inside one single namespace only. A ClusterRoleBinding applies permissions across every namespace and cluster-scoped resource.

How does Kubernetes control access to pod logs and container shells?

Kubernetes uses subresources that you write with a slash in your RBAC rules. You grant specific rights to the log or execution subresource under the pods resource.

The query runs. The emails stay hidden.