Skip to content

OIDC Login ​

The ESC Kubernetes Service supports OIDC-based authentication for kubectl access using the kubelogin plugin (also known as kubectl oidc-login). This plugin enables browser-based Single Sign-On (SSO) directly from the command line, eliminating the need for manually managing tokens.

Overview ​

When kubectl is configured with the kubelogin plugin, the following authentication flow is executed automatically:

  1. A kubectl command is issued (e.g., kubectl get pods)
  2. The kubelogin plugin starts a local server and opens the browser for OIDC authentication
  3. The user authenticates via the Identity Provider of his ESC Tenant
  4. kubelogin receives the OIDC token and passes it to kubectl
  5. kubectl accesses the Kubernetes API with the token

Tokens are cached locally under ~/.kube/cache/oidc-login/. When a cached token is still valid, no browser interaction is required. Expired tokens are refreshed automatically using the refresh token. If the refresh token has also expired, the browser-based login is triggered again.

Installing kubelogin ​

The kubelogin plugin can be installed using one of the following methods:

bash
brew install kubelogin
bash
kubectl krew install oidc-login
bash
choco install kubelogin

Verify Installation

After installation, verify that the plugin is available:

bash
kubectl oidc-login --help

Manual Installation

When installing from GitHub Releases, the binary must be saved as kubectl-oidc_login and placed on the system PATH. The other installation methods handle this automatically.

Downloading the Kubeconfig ​

The KKP Dashboard provides a kubeconfig download with the kubelogin plugin pre-configured:

  1. Navigate to Clusters and select the target cluster
  2. Click the Get Kubeconfig (top right corner of the cluster detail page)
  3. In the download dialog, select the OIDC via oidc-login plugin authentication method
  4. Save the kubeconfig file

Using kubectl with kubelogin ​

Once the kubeconfig has been downloaded, set the KUBECONFIG environment variable and use kubectl as usual:

bash
export KUBECONFIG=~/Downloads/kubeconfig-YOUR-CLUSTER-ID
kubectl get nodes

On the first invocation (or when the token has expired), a browser window will open automatically. The user authenticates via the Identity Provider and is redirected back to the local kubelogin server. After successful authentication, kubectl completes the requested operation.

kubelogin localhost:8000

The kubelogin plugin starts a local HTTP server on port 8000 (or 18000 as fallback). These ports must not be blocked by a local firewall or occupied by another application.

Kubeconfig Structure ​

A kubeconfig configured for kubelogin uses the exec-based credential plugin mechanism. The users section looks as follows:

yaml
users:
  - name: user@example.com
    user:
      exec:
        apiVersion: client.authentication.k8s.io/v1
        args:
          - oidc-login
          - get-token
          - --oidc-issuer-url=https://<KKP_DASHBOARD_URL>/dex
          - --oidc-client-id=kubermaticIssuer
          - --oidc-client-secret=<SECRET>
          - --oidc-extra-scope=email
          - --oidc-extra-scope=groups
        command: kubectl
        env: null
        interactiveMode: Never
        provideClusterInfo: false

⚠️ Beware!

The --oidc-client-secret value is included in the downloaded kubeconfig. This secret should be treated as confidential and the kubeconfig file should not be shared or committed to version control.

Token Management ​

Token Cache ​

kubelogin stores tokens in a local cache at ~/.kube/cache/oidc-login/. The cached tokens are used for subsequent kubectl calls without requiring re-authentication.

To clear the token cache (effectively logging out):

bash
kubectl oidc-login clean

After clearing the cache, the next kubectl command will trigger browser-based authentication again.

Clearing the browser session

If the browser still has an active session cookie with the Identity Provider, clearing the kubelogin cache alone may result in automatic re-authentication without user interaction. To fully log out, the session in the Identity Provider should also be terminated.

Revoking Access ​

Cluster administrators can revoke access tokens from the KKP Dashboard:

  1. Navigate to the cluster detail page
  2. Click the three-dot settings icon (top right)
  3. Select Revoke Token

After revocation, all previously downloaded kubeconfigs for the affected user group become unusable. Users will need to download a new kubeconfig.