KCP Administrator Sign-in#
Let your platform administrators sign in to KCP, the SCO control plane, with their own identity from your OIDC provider, instead of sharing one admin credential. The audit log then names the person who made each change.
Note
This page covers sign-in to KCP only. Sign-in to the hosting OpenShift cluster is not affected.
Sam, a platform administrator at ACME Corp, today uses a shared admin kubeconfig for KCP. Sam's team wants each administrator to sign in as themselves, with access managed through a group in their identity provider.
Prerequisites#
- A
KubeStackConfigon kubestack-config 0.9.4 or later. The dev variant is not supported. - An OIDC provider whose certificate is publicly trusted. This can be the platform's own login service or your own identity provider (IdP).
- A group in that provider for your administrators.
- On each administrator's machine:
kubectland thekubeloginplugin (kubectl oidc-login).
Private certificate authorities
An issuer whose certificate comes from a private CA is not supported yet.
How it works#
- Administrators sign in through the control plane's front proxy, which checks their token against the issuer you configure. Tenant sign-in is not affected.
- Administrator identities get the prefix
provider:(for exampleprovider:sam@acme.example). Tenant identities use a different prefix, so the two can never match each other's role-based access. - Members of the admin groups become administrators of the control plane and of every organisation and project.
- The shared admin credential keeps working. The platform still uses it for its own automation.
Step 1: Prepare the login client#
The client must be a public client (no client secret) that allows the
kubelogin callback addresses http://localhost:8000 and
http://localhost:18000. Its tokens must carry the user's email and groups.
With the platform's own login service, the platform creates the client for
you. Use the cluster realm as the issuer and set clusterRealmClient: true in
Step 2. The groups claim carries your Azure groups by object ID.
With your own IdP, create the client there before Step 2, with:
- the two callback addresses above
- an
emailclaim (or setusernameClaim) - a
groupsclaim listing the user's groups (or setgroupsClaim)
Step 2: Turn it on in the KubeStackConfig#
Add kcpAdminAuth to spec.parameters of your KubeStackConfig claim:
spec:
parameters:
kcpAdminAuth:
issuerURL: https://<login-host>/realms/<cluster-realm>
clientID: kcp
adminGroups:
- <admin-group>
clusterRealmClient: true # only with the platform's own login service
| Field | Description | Default |
|---|---|---|
issuerURL |
Issuer of the OIDC provider, exactly as it appears in the token's iss claim |
Required |
clientID |
The public client from Step 1 | Required |
adminGroups |
Groups whose members become administrators, written exactly as the provider puts them in the groups claim (a name or an ID) | Required |
usernameClaim |
Token claim used as the user name | email |
groupsClaim |
Token claim that lists the user's groups | groups |
clusterRealmClient |
Create the client in the cluster's own realm. Set it only when issuerURL is that realm |
false |
Applying the change restarts the control plane's front proxy. Expect a short interruption for everyone who uses the control plane.
Tip
If you use branded URLs, check which login hostname issues your tokens and use that issuer. A token from one hostname is not valid for an issuer on the other.
Step 3: Get the control plane's CA certificate#
The control plane serves its own certificate. Each administrator needs its CA certificate (no private key). On the hosting cluster, run:
oc get secret root-server-ca -n kcp-config \
-o jsonpath='{.data.tls\.crt}' | base64 -d > sco-control-plane-ca.crt
The CA certificate is long-lived (ten years by default), so you can hand it out once.
Step 4: Create the kubeconfig#
export KUBECONFIG=~/.kube/sco-admin
kubectl config set-cluster sco \
--server=https://<control-plane-host>/clusters/root \
--certificate-authority=sco-control-plane-ca.crt --embed-certs
kubectl config set-credentials sco-admin \
--exec-api-version=client.authentication.k8s.io/v1 \
--exec-interactive-mode=IfAvailable \
--exec-command=kubectl \
--exec-arg=oidc-login \
--exec-arg=get-token \
--exec-arg=--oidc-issuer-url=<issuerURL> \
--exec-arg=--oidc-client-id=kcp \
--exec-arg=--oidc-extra-scope=email
kubectl config set-context sco --cluster=sco --user=sco-admin
kubectl config use-context sco
<control-plane-host> is the control plane's external hostname, for example
dev.kcp.apps.<cluster-domain>.
Step 5: Verify#
kubectl auth whoami
The first command opens your browser to sign in. Afterwards you should see:
ATTRIBUTE VALUE
Username provider:sam@acme.example
Groups [provider:<admin-group> ... system:authenticated]
Check that you are an administrator:
kubectl auth can-i '*' '*'
Work in other workspaces#
The kubeconfig points at the root of the control plane. To work in an organisation or a project, change the path at the end of the server address:
kubectl --server=https://<control-plane-host>/clusters/root:cloud:<organisation> get workspaces
kubectl --server=https://<control-plane-host>/clusters/root:cloud:<organisation>:<project> get all
Sign out#
kubectl oidc-login clean
This removes the cached tokens. The next command asks you to sign in again.
Turn it off#
Delete the kcpAdminAuth block from the KubeStackConfig. The front proxy
restarts and the administrators lose their access. The shared admin credential
keeps working.
What's Next?#
- Branded URLs - Serve the portal and login page on your own hostnames
- Platform Configuration - Change other platform settings
- KCP - How the control plane's workspaces are organised