Kubernetes
LDAP
User Authentication
Kubernetes Security
Identity Management

LDAP based user authentication for Kubernetes

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Kubernetes does not offer a native "bind to LDAP and authenticate users directly" mode in the API server. In practice, LDAP-backed Kubernetes login is implemented through an identity layer, most commonly an OIDC provider that authenticates against LDAP and then issues tokens that the API server trusts.

Understand the Authentication Boundary

The kube-apiserver supports built-in authentication methods such as client certificates and service-account tokens, plus external integrations such as OIDC, webhook token authentication, and authenticating proxies. Direct username-and-password LDAP auth is not the normal API-server boundary.

That means the architecture usually looks like this:

text
1LDAP or Active Directory
2        |
3identity provider
4        |
5OIDC token
6        |
7kube-apiserver
8        |
9RBAC authorization

This separation is useful because Kubernetes prefers signed tokens rather than raw directory credentials. Your identity system handles password validation and directory lookup, while Kubernetes focuses on token verification and authorization.

Preferred Pattern: OIDC Backed by LDAP

The most maintainable design for most clusters is:

  • connect an identity provider such as Dex, Keycloak, or Pinniped to LDAP
  • configure the provider to issue OIDC-compatible tokens
  • configure the API server to trust that issuer
  • map token claims such as username and groups into RBAC

A simplified Dex LDAP connector looks like this:

yaml
1connectors:
2  - type: ldap
3    id: ldap
4    name: LDAP
5    config:
6      host: ldap.example.com:636
7      insecureNoSSL: false
8      bindDN: uid=svc-k8s,ou=service,dc=example,dc=com
9      bindPW: super-secret-password
10      userSearch:
11        baseDN: ou=users,dc=example,dc=com
12        filter: "(objectClass=person)"
13        username: uid
14        idAttr: uid
15        emailAttr: mail
16        nameAttr: cn
17      groupSearch:
18        baseDN: ou=groups,dc=example,dc=com
19        filter: "(objectClass=groupOfNames)"
20        userMatchers:
21          - userAttr: DN
22            groupAttr: member
23        nameAttr: cn

The directory is still the source of truth for users and groups, but Kubernetes only sees the resulting token claims.

Configure the API Server to Trust the Issuer

Once the identity provider is in place, configure the API server to trust it. Modern Kubernetes supports structured authentication configuration for JWT and OIDC-style issuers.

yaml
1apiVersion: apiserver.config.k8s.io/v1
2kind: AuthenticationConfiguration
3jwt:
4  - issuer:
5      url: https://dex.example.com
6      audiences:
7        - kubernetes
8    claimMappings:
9      username:
10        claim: email
11        prefix: ""
12      groups:
13        claim: groups
14        prefix: ""

With a configuration like that, the API server validates the token signature, checks the issuer, checks the audience, and extracts user identity from claims such as email and groups.

If your environment still uses the older --oidc-* flags, that can work too, but it is the same basic pattern: Kubernetes trusts an external issuer rather than talking to LDAP directly.

RBAC Is Where LDAP Group Membership Becomes Access

Authentication proves who the user is. Authorization determines what that user can do. This is where many LDAP-based setups fail: the login works, but there is no RBAC binding for the mapped group.

For example, if the OIDC token includes a groups claim with the value developers, you can bind it to a standard cluster role:

yaml
1apiVersion: rbac.authorization.k8s.io/v1
2kind: ClusterRoleBinding
3metadata:
4  name: developers-view
5subjects:
6  - kind: Group
7    name: developers
8    apiGroup: rbac.authorization.k8s.io
9roleRef:
10  kind: ClusterRole
11  name: view
12  apiGroup: rbac.authorization.k8s.io

At that point, directory-managed group membership turns into Kubernetes permissions. If the group claim name or prefix does not match what RBAC expects, authentication succeeds but authorization still fails.

Alternatives: Webhook or Authenticating Proxy

OIDC is not the only option. Kubernetes also supports:

  • webhook token authentication
  • an authenticating reverse proxy

These are useful when you already have existing enterprise identity infrastructure or non-OIDC token flows. A webhook service can validate a token that represents an LDAP-authenticated user and return username and groups to the API server. An authenticating proxy can sit in front of Kubernetes and pass trusted identity headers.

Those approaches are valid, but they usually require more custom infrastructure than an LDAP-backed OIDC provider. For most teams, OIDC is the cleanest balance of compatibility and operational simplicity.

Common Pitfalls

The biggest mistake is assuming the API server has a first-class --ldap-* mode. It does not. Current Kubernetes authentication is centered on tokens and trusted identity integrations.

Another common mistake is solving login without solving RBAC. A user can authenticate successfully and still receive Forbidden if the token's username or groups are not bound to any role.

Teams also often forget claim prefixes. If your identity provider emits oidc:developers but your ClusterRoleBinding expects developers, the binding will never match. Finally, do not use plaintext LDAP. Protect directory traffic with TLS and use a minimal bind account.

Summary

  • Kubernetes normally uses LDAP through an identity provider, not through direct native LDAP auth in the API server.
  • The common production pattern is LDAP to OIDC provider to kube-apiserver to RBAC.
  • Configure the API server to trust the token issuer and map username and group claims carefully.
  • RBAC bindings must match the actual claims in the token or users will authenticate without authorization.
  • Webhook and authenticating-proxy patterns exist, but OIDC-backed federation is usually the most maintainable option.

Course illustration
Course illustration

All Rights Reserved.