AuthenticationKubernetes · OpenID
Sign in to Kubernetes with OIDC in place of shared kubeconfigs
With a client certificate, Kubernetes takes the username from the certificate's common name. With OpenID Connect, the API server reads the username and groups from a token that your identity provider issues to each person.

How Kubernetes identifies a user
Kubernetes does not have objects that represent normal user accounts, and normal users cannot be added through an API call. Kubernetes treats a user as authenticated once they present a valid certificate that the cluster's certificate authority signed. Kubernetes reads the username from the certificate: it is the common name field of the subject.
Kubernetes also has native support for OpenID Connect (OIDC). kubectl sends the ID token from your identity provider to the API server.
How the API server checks a token
The ID token is a JSON web token. The Kubernetes documentation describes what the API server does with it:
- It makes sure the signature is valid. The public key is discovered from the issuer's endpoint through OIDC discovery.
- It checks that the token has not expired. The
issclaim must match the configured issuer URL, and theaudclaim must match a configured audience. - It takes the username and the groups from the claims you configure.
- It makes sure the user is authorized.
Kubernetes does not need to contact the identity provider, because all the data needed to validate the user is in the ID token. The same page says the ID token cannot be revoked, so it should be short-lived, only a few minutes.
Option 1, the OIDC flags
kubelogin's setup guide gives the two flags to add to kube-apiserver:
--oidc-issuer-url=ISSUER_URL
--oidc-client-id=YOUR_CLIENT_IDThese two are required, and the issuer URL must use the https:// scheme. The Kubernetes documentation lists optional flags, among them:
--oidc-username-claim: the claim to use as the user name. The default issub, and other claims such asemailcan be chosen.--oidc-username-prefix: prevents clashes with existing names such assystem:users. With the valueoidc:, usernames look likeoidc:jane.doe.--oidc-groups-claim: the claim to use as the user's groups. If present, it must be an array of strings.--oidc-groups-prefix: with the valueoidc:, group names look likeoidc:engineering.
Multiple authenticators, and multiple audiences for one issuer, are available only with the configuration file.
Option 2, structured authentication configuration
The configuration file is passed with --authentication-config. It has been stable since Kubernetes v1.34 and was first available in v1.29. This is an example from the Kubernetes documentation, with a typo in the message corrected:
apiVersion: apiserver.config.k8s.io/v1
kind: AuthenticationConfiguration
jwt:
- issuer:
url: https://example.com
audiences:
- my-app
claimMappings:
username:
expression: 'claims.username + ":external-user"'
groups:
expression: 'claims.roles.split(",")'
uid:
expression: 'claims.sub'
extra:
- key: 'example.com/tenant'
valueExpression: 'claims.tenant'
userValidationRules:
- expression: "!user.username.startsWith('system:')"
message: 'username cannot use reserved system: prefix'In the documentation, a token with the username foo and the roles user,admin becomes the user foo:external-user in the groups user and admin.
The file adds these capabilities:
- multiple JWT authenticators, 64 at most
- multiple audiences for one issuer
- CEL expressions that map claims to user attributes and validate claims and user information
- a reload when the file is modified, while the API server is running
The two options cannot be combined. If --authentication-config is specified along with any --oidc-* argument, the API server reports an error and immediately exits.
Sign in from kubectl
Kubernetes offers no web interface that starts the authentication process. kubelogin, from the int128/kubelogin repository, is a kubectl plugin also known as kubectl oidc-login. kubectl runs it ahead of each call to the Kubernetes API, the plugin opens a browser for the sign-in, and it hands the credentials back to kubectl.
Its README installs it with brew install kubelogin or kubectl krew install oidc-login. These two commands are from its setup guide. The first shows setup instructions and dumps the claims of an ID token from the provider. The second adds the user to the kubeconfig:
kubectl oidc-login setup \
--oidc-issuer-url=ISSUER_URL \
--oidc-client-id=YOUR_CLIENT_ID
kubectl config set-credentials oidc \
--exec-interactive-mode=Never \
--exec-api-version=client.authentication.k8s.io/v1 \
--exec-command=kubectl \
--exec-arg=oidc-login \
--exec-arg=get-token \
--exec-arg=--oidc-issuer-url=ISSUER_URL \
--exec-arg=--oidc-client-id=YOUR_CLIENT_IDThe setup guide says you can share this kubeconfig with team members for onboarding. It also recommends adding --token-cache-storage=keyring, because kubelogin stores the token cache on the file system by default.
kubelogin refreshes an expired ID token with the refresh token, and performs the authentication again when the refresh token has expired.
Azure's kubelogin is a different plugin. It implements Microsoft Entra authentication for AKS.
Map groups to RBAC
RBAC subjects can be groups. This is the ClusterRoleBinding example from the Kubernetes documentation. Through a ClusterRole named secret-reader, it lets every user in the manager group read secrets in all namespaces:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-secrets-global
subjects:
- kind: Group
name: manager # Name is case sensitive
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: secret-reader
apiGroup: rbac.authorization.k8s.ioWhen a groups prefix is set, bind the prefixed name, such as oidc:engineering. To see the username and groups the cluster maps to you, run kubectl auth whoami.
Managed clusters
Amazon EKS supports associating OIDC identity providers with a cluster. IAM authentication cannot be disabled, and clusters on Kubernetes 1.32 or later accept up to 10 providers, while earlier versions accept one. AKS has a Microsoft Entra integration that cannot be disabled once enabled, and Entra groups are included only by their object ID. For GKE, Google recommends Workforce Identity Federation. Identity Service for GKE is deprecated since 1 July 2026 and unsupported in GKE version 1.37 and later.
What to check before you switch
- The provider. Kubernetes requires three things of an identity provider: it supports OIDC discovery, it runs TLS with non-obsolete ciphers, and it has a CA-signed certificate.
- The claims. Read the claims that
kubectl oidc-login setupprints. The token must contain the configured username claim, and a groups claim must be an array of strings.
Sources
- Authenticating
- Using RBAC Authorization
- kubelogin
- Kubernetes OpenID Connection authentication
- Grant users access to Kubernetes with an external OIDC provider
- Enable Microsoft Entra ID authentication for the AKS control plane
- Use kubelogin to authenticate users in Azure Kubernetes Service (AKS)
- Use external identity providers to authenticate to GKE
Want a second pair of eyes on yours? We do this work for a living.
More guides

Kubernetes RBAC: five rules for least privilege
Security · 2 min read
Groups over users, namespaces over clusters, and how to test what an account can do.

Workload identity on EKS, AKS and GKE: pods without cloud keys
Authentication · 4 min read
The role association, annotation, label or IAM binding that each of the three platforms needs.

AWS IAM Identity Center: one sign-in for many accounts
Authentication · 4 min read
Identity sources, permission sets, CLI sign-in and the case against an IAM user in each account.