Install kubelogin
Kestrel uses int128/kubelogin, a kubectl credential plugin that logs you in to Keycloak over OIDC and caches the token. Microsoft’s Azure AD tool, also called kubelogin, is a different program; if your package manager offers both, pick int128/kubelogin.
Install
Section titled “Install”brew install kubeloginWithout Homebrew, download kubelogin_darwin_arm64.zip or kubelogin_darwin_amd64.zip from the release page, extract it, and put the binary on your PATH.
With Krew:
kubectl krew install oidc-loginKrew installs it as kubectl oidc-login, which is what the kubeconfig below calls.
Alternatively, use Linuxbrew (brew install kubelogin) or download kubelogin_linux_amd64.zip from the release page. It is not packaged for apt, yum or dnf.
With Chocolatey:
choco install kubeloginAlternatively, use Krew (kubectl krew install oidc-login) or download kubelogin_windows_amd64.zip from the release page, extract it, and put kubelogin.exe on your PATH.
Configure your kubeconfig
Section titled “Configure your kubeconfig”Merge this into ~/.kube/config, or keep it in a separate file and use KUBECONFIG=~/.kube/config-kestrel kubectl ... while you test.
apiVersion: v1kind: Configclusters: - name: kestrel cluster: server: https://proxy.kestrel.arbutus.cloudcontexts: - name: kestrel context: cluster: kestrel user: kestrel-oidccurrent-context: kestrelusers: - name: kestrel-oidc user: exec: apiVersion: client.authentication.k8s.io/v1 command: kubectl args: - oidc-login - get-token - --oidc-issuer-url=https://keycloak.arbutus.alliancecan.ca/realms/atmosphere - --oidc-client-id=kubernetes - --token-cache-storage=keyring interactiveMode: IfAvailable provideClusterInfo: falseThe server is capsule-proxy, which filters cluster-scoped lists such as kubectl get ns to your tenant and forwards requests to the API server.
command: kubectl with oidc-login as the first argument needs a binary named kubectl-oidc_login on your PATH. Krew, Homebrew and Chocolatey set that up. If you downloaded the binary by hand, either rename it to kubectl-oidc_login (kubectl-oidc_login.exe on Windows), or set command: to the path of your kubelogin binary and remove the oidc-login argument.
First login
Section titled “First login”kubectl auth whoamikubeloginopens your browser at the Keycloak login page.- Log in with your Alliance CCDB username and password.
- Keycloak redirects to
localhost:8000, wherekubeloginis listening. Close the tab when it says login is complete.
The command then prints your identity:
ATTRIBUTE VALUEUsername testuserGroups [oidc:def-testuser system:authenticated]The oidc: group is your Cloud RAP group, which grants access to your tenant. Your tenant name is that group name lowercased (oidc:CCInternal-RAID → tenant ccinternal-raid). See Identity chain.
kubelogin caches the token and refreshes it against Keycloak without prompting. On a new tenant, kubectl get ns returns an empty list until you create a namespace in Your first deployment.
Troubleshooting
Section titled “Troubleshooting”Port 8000 already in use
Section titled “Port 8000 already in use”Symptom: the browser shows “Unable to connect” after the Keycloak login, and kubelogin hangs.
Cause: kubelogin listens on localhost:8000 and falls back to localhost:18000. Both are taken (a dev server, an old kubelogin process, a Docker port) or the fallback is blocked.
Fix: free port 8000 or 18000 and retry.
State does not match
Section titled “State does not match”Symptom: after you authenticate, Keycloak shows “State does not match” or a similar OIDC state error.
Cause: stale state from an aborted login, or an old tab that followed a previous callback.
Fix:
kubectl oidc-login cleankubectl auth whoamiIf it persists, use a fresh or private browser window.
Browser does not open, or opens but the login never completes
Section titled “Browser does not open, or opens but the login never completes”Symptom: kubectl auth whoami hangs with no browser, or the browser errors before or after the Keycloak page.
Cause: there is no GUI (WSL2, tmux, SSH), or the default browser is sandboxed (Flatpak or Snap) or misregistered.
Fix (same machine): add --skip-open-browser to exec.args. kubelogin prints a localhost:8000 URL; open it in any browser on that machine.
Fix (remote shell): add --skip-open-browser, then forward the callback port from your workstation to the machine running kubectl (not a Kestrel or Keycloak host):
ssh -L 8000:localhost:8000 <user>@<remote-host>kubectl auth whoami is missing your tenant group
Section titled “kubectl auth whoami is missing your tenant group”Symptom: login completes, but Groups shows only system:authenticated, with no oidc:<RAP group>. (An empty kubectl get ns is not this failure.)
Cause: usually RCS hasn’t added you to the tenant’s Keycloak group yet; CCDB sponsorship alone doesn’t grant access. Less often, your CCDB account is new and hasn’t synced to Keycloak, so RCS can’t add you yet. Ask your PI to confirm the request (Managing membership).
Fix: once RCS confirms the add, clear the token and log in again:
kubectl oidc-login cleankubectl auth whoamiIf the group is still missing, check your CCDB account with accounts@tech.alliancecan.ca.