Custom Load Balancer Kubernetes

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a custom load balancer kubernetes setup by running a controller that watches service endpoints. This controller updates your external routing rules whenever pods start or stop. Teams often give this controller and their engineers broad cluster permissions to make setup fast. Broad roles create big risks when someone runs a bad command or reads secret data. How a custom load balancer kubernetes setup works A Kubernetes cluster does not move external network traffic on its own. Inste

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 a custom load balancer kubernetes setup by running a controller that watches service endpoints. This controller updates your external routing rules whenever pods start or stop. Teams often give this controller and their engineers broad cluster permissions to make setup fast. Broad roles create big risks when someone runs a bad command or reads secret data.

How a custom load balancer kubernetes setup works

A Kubernetes cluster does not move external network traffic on its own. Instead, it relies on an external tool or a controller pod inside the cluster. This controller watches the API server for changes to services and pod IP addresses. When a pod starts or stops, the controller updates the external routing table.

To do this job, the controller needs permissions through Kubernetes Role-Based Access Control. In Kubernetes RBAC, a Role sets permissions inside one single namespace. A ClusterRole sets permissions across the whole cluster, including nodes and all namespaces. You attach these rules to users or service accounts with a RoleBinding or ClusterRoleBinding.

Permissions in Kubernetes RBAC are purely additive, which means there are no deny rules. If you give a controller a ClusterRoleBinding, it can read resources across every namespace. Engineers also need roles to check the load balancer state and read pod logs. In RBAC, you grant log reading through a subresource rule written with a slash. You can also grant interactive shell rights through the pod exec subresource rule.

What native routing and RBAC leave open

Native Kubernetes RBAC controls who can talk to the API server and start a session. It does a good job of letting your load balancer controller read node and service states. It also lets you limit which namespaces an engineer can touch during an outage.

Still, native RBAC stops working after the initial check passes. Once an engineer opens an exec shell to fix a routing pod, RBAC steps aside. It does not inspect individual commands running inside that shell session. An engineer with exec rights can read local files, change routing tables, or view secrets.

Kubernetes RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

The same gap exists when traffic or admin requests hit your internal services. A load balancer routes network packets to the right pod, and RBAC checks the role. Neither tool inspects the actual queries or commands sent inside that active session. Also, RBAC resource name limits on create actions apply only to top-level resources, not subresources. You cannot use native RBAC alone to block specific risky commands inside a running pod. Teams also struggle when sensitive fields like emails, phone numbers, or card numbers pass through logs. Native cluster roles do not rewrite matched fields in results before an engineer sees them.

Securing engineer workflows around cluster routing

To keep your cluster safe, separate machine roles from human admin roles right away. Give your load balancer service account a narrow role that only reads service endpoints. Do not let human engineers share that same service account to debug network issues.

For human engineers, avoid granting permanent cluster-wide exec permissions across production namespaces. Use RoleBindings inside single namespaces instead of wide ClusterRoleBindings whenever you can. Review your role definitions often to remove unused subresource permissions like pod exec. Because RBAC has no deny rules, you must keep base roles very small from day one. Finally, look at how you control and log the actual commands engineers run during live debugging.

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

Can I use deny rules in Kubernetes RBAC to block load balancer changes?

No, Kubernetes RBAC permissions are purely additive and do not support deny rules. You must start with zero permissions and only add the exact rules each role needs.

Should a load balancer controller use a Role or a ClusterRole?

A controller that watches services across all namespaces needs a ClusterRole and a ClusterRoleBinding. If it only manages traffic for one specific namespace, use a Role and a RoleBinding.

Does Kubernetes RBAC filter what commands run inside a pod exec session?

No, RBAC only checks if a user has permission to open the exec subresource. Once the session starts, native RBAC does not inspect or block individual shell commands.

The query runs. The emails stay hidden.