Skip to content

triauth for KubernetesOIDC

Let your engineers sign in to your Kubernetes clusters from kubectl with one approval on their own device, and no certificates or long-lived tokens to hand out.

  • Code and DevOps
  • Open source
Sign-in through
OpenID Connect bridge
Available in
Self-managed clusters, and Amazon EKS
Set up in
kube-apiserver flags and kubeconfig

About Kubernetes

Kubernetes runs containerised applications across a fleet of servers and is the platform most operations teams deploy onto. Engineers talk to a cluster through its API with kubectl, and the cluster has to know who is calling. With OpenID Connect, the cluster accepts a token from the bridge as the engineer's identity, and a small kubectl plugin, kubelogin, fetches it.

Connect Kubernetes to triauth

Kubernetes signs engineers in through the triauth OpenID Connect bridge, with the kubelogin plugin on their computers. When an engineer runs kubectl, kubelogin opens the browser at the bridge, they type their username and approve on their own device, and the command runs. Nobody hands out certificates or long-lived tokens, and when someone leaves, removing their identity records at your domain ends their access to the cluster as well.

How it works

  1. Open oidc.triauth.org and enter your domain. Paste kubelogin's redirect address, http://localhost:8000, and click Connect app. The bridge gives you a client ID and a client secret.

  2. Start kube-apiserver with the flags below, with your domain in place of example.com and the client ID from the bridge in place of the placeholder.

    ini
    --oidc-issuer-url=https://oidc.triauth.org/example.com
    --oidc-client-id=<client ID from the bridge>
    --oidc-username-claim=email
    --oidc-groups-claim=groups
    --oidc-groups-prefix=oidc:
  3. On each engineer's computer, install kubelogin with kubectl krew install oidc-login, then add the user to their kubeconfig. Replace example.com with your domain and the two placeholders with the client ID and the client secret from the bridge.

    sh
    kubectl config set-credentials example.com \
      --exec-api-version=client.authentication.k8s.io/v1 \
      --exec-interactive-mode=Never \
      --exec-command=kubectl \
      --exec-arg=oidc-login \
      --exec-arg=get-token \
      --exec-arg=--oidc-issuer-url=https://oidc.triauth.org/example.com \
      --exec-arg=--oidc-client-id=<client ID from the bridge> \
      --exec-arg=--oidc-client-secret=<client secret from the bridge> \
      --exec-arg=--oidc-extra-scope=email \
      --exec-arg=--oidc-extra-scope=groups \
      --exec-arg=--oidc-extra-scope=offline_access \
      --exec-arg=--listen-address=127.0.0.1:8000
  4. Give a group its rights, for example kubectl create clusterrolebinding platform --clusterrole=cluster-admin --group=oidc:platform@example.com, and point the engineers' context at the new user.

  5. Run kubectl get pods.

Checkpoint

The first kubectl command opens the browser at a page from the bridge that asks for the username, and the engineer's authenticator asks them to approve. The browser then shows a page from kubelogin that says it is done, and the command prints its result.

Good to know

  • Kubernetes keeps no user records. An engineer has no rights until a role binding names their identifier, such as john@example.com, or one of their groups. To let only one team in, limit the app to a group when you connect it.
  • The groups published at your domain arrive with the prefix from step 2, so oidc:platform@example.com in a role binding covers everyone in the platform team.
  • kubelogin keeps the sign-in on the engineer's computer and renews it through the bridge without anyone noticing. The browser opens again only once the bridge stops renewing it, for example after a long time without kubectl. The cluster stops accepting someone at the first renewal after their identity records go away.

For the person who connects the app

SettingValue
Redirect addresshttp://localhost:8000, kubelogin's own. The --listen-address flag keeps it from falling back to a second port
Wherethe API server's --oidc-* flags, or an AuthenticationConfiguration file on Kubernetes 1.30 and newer, and the exec section of each engineer's kubeconfig
Issuerhttps://oidc.triauth.org/<your domain>, which the API server must reach to read the signing keys
Client secretkubelogin sends it from the kubeconfig, as its own setup guide does, so it sits there in clear text on every engineer's computer. The secret is what lets the bridge keep an engineer signed in instead of asking for an approval each time its short-lived token expires
Scopesemail, groups, and offline_access on top of openid, each as its own --oidc-extra-scope
User names--oidc-username-claim=email makes the user name the identifier, with no issuer prefix. The groups prefix keeps the groups apart from the cluster's own
Managed clustersAmazon EKS takes an OIDC identity provider with the same issuer and client ID. Google's and Azure's managed offerings use mechanisms of their own, which this page does not cover
Token cachekubelogin usually keeps the tokens under ~/.kube/cache/oidc-login, or in the system keyring with --token-cache-storage=keyring, which its guide recommends. A failed renewal, also one during a bridge outage, opens the browser for a new sign-in

kubelogin keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge. Kubernetes' authentication reference explains every flag, and kubelogin's setup guide walks through the kubeconfig.

Next steps

All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.