Appearance
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:
- A
kubectlcommand is issued (e.g.,kubectl get pods) - The kubelogin plugin starts a local server and opens the browser for OIDC authentication
- The user authenticates via the Identity Provider of his ESC Tenant
- kubelogin receives the OIDC token and passes it to
kubectl kubectlaccesses 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 kubeloginbash
kubectl krew install oidc-loginbash
choco install kubeloginVerify Installation
After installation, verify that the plugin is available:
bash
kubectl oidc-login --helpManual 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:
- Navigate to Clusters and select the target cluster
- Click the Get Kubeconfig (top right corner of the cluster detail page)
- In the download dialog, select the OIDC via oidc-login plugin authentication method
- 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 nodesOn 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 cleanAfter 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:
- Navigate to the cluster detail page
- Click the three-dot settings icon (top right)
- Select Revoke Token
After revocation, all previously downloaded kubeconfigs for the affected user group become unusable. Users will need to download a new kubeconfig.
