Openldap K8s

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openldap k8s access by connecting your directory groups to native cluster roles. An login layer checks user logins against your directory before the API server applies permissions. Platform teams often map broad directory groups to cluster-wide admin roles to save time. When a role is too broad, any user in that group can alter workloads. They can also read secrets or run shell commands inside sensitive pods. How openldap k8s authentication and RBAC work Kubernetes does not have 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 openldap k8s access by connecting your directory groups to native cluster roles. An login layer checks user logins against your directory before the API server applies permissions. Platform teams often map broad directory groups to cluster-wide admin roles to save time. When a role is too broad, any user in that group can alter workloads. They can also read secrets or run shell commands inside sensitive pods.

How openldap k8s authentication and RBAC work

Kubernetes does not have a built-in user database or a native LDAP client. Instead, the API server relies on external tools to check user credentials at login. Teams deploy an identity provider or webhook service that talks to the directory server. When an engineer logs in, that service checks the username and group list in LDAP. It then passes the verified user identity and group names back to the Kubernetes API server.

Once the API server knows who the user is, native role-based access control takes over. In Kubernetes RBAC, a Role sets permissions inside a single namespace. A ClusterRole sets permissions across the whole cluster and covers cluster-scoped objects like nodes. You link an LDAP group name to these permissions with a RoleBinding or a ClusterRoleBinding. A RoleBinding grants access inside one namespace, even if it points to a ClusterRole. A ClusterRoleBinding grants those permissions across every namespace in the cluster at once.

Why native roles are purely additive

In Kubernetes RBAC, permissions are additive, which means there are no deny rules. If a user belongs to three LDAP groups, they get the sum of all linked roles. You cannot write a rule that takes away one specific action from a broad group. To restrict a user, you must split the directory groups and rebuild your bindings from scratch.

RBAC also uses subresources to control actions like reading pod logs or running commands. The API server treats a pod log check or a shell session as a distinct subresource. You must grant permission to the pod exec subresource before a user can open a shell. Many teams grant wildcard rights on pods so developers can fix broken apps during an outage. That single rule lets everyone in the LDAP group open a shell inside any running container.

K8s Namespace Isolation: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What directory bindings solve and what they leave open

Mapping directory groups to native roles solves the problem of who can reach the cluster API. When someone leaves the company, you remove them from the LDAP directory. Their cluster access stops as soon as their current login token expires. You do not need to edit cluster manifests by hand every time an engineer changes teams.

Still, directory group bindings only decide who can start a session or call an API endpoint. Once the API server allows a pod exec request, native RBAC steps out of the way. It does not inspect the shell commands that the user runs inside the container. It also cannot mask sensitive data like emails, phone numbers, card numbers, or national IDs in output. If a pod holds database keys in its memory, a user with exec rights can read them. Native audit logs record that a shell session started, but not the commands typed inside it.

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 runs as an open-source proxy, a sidecar for your Kubernetes API, checking requests and responses without replacing RBAC.

First, hoop.dev guardrails refuse banned methods, paths, or headers before they run. 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 Kubernetes talk to an OpenLDAP server without extra tools?

No, the API server does not speak the LDAP protocol on its own. You must run an external identity provider or login webhook to check directory logins first.

How do I stop an LDAP group from using pod exec in one namespace?

Because Kubernetes RBAC has no deny rules, you cannot block just one action from a broad binding. Replace your ClusterRoleBinding with separate RoleBindings per namespace, and leave out the exec subresource where needed.

Does the cluster audit log show what users type inside a pod shell?

No, the native API server audit log only records that the user opened an exec subresource connection. It does not capture the standard input or output stream of the shell session itself.

The query runs. The emails stay hidden.