Kubernetes Impersonation
By default, Kite connects to each cluster using the cluster's configured credentials (in-cluster ServiceAccount, kubeconfig, or Cluster Agent ServiceAccount): multi-tenant permissions are enforced inside Kite via RBAC Configuration, while kube-apiserver sees every request as coming from Kite's ServiceAccount.
When Kubernetes Impersonation is enabled on a cluster, Kite attaches Impersonate-User and Impersonate-Group headers to requests sent to kube-apiserver, acting on behalf of the currently logged-in Kite user.
How It Works (Why Cluster RBAC Matters)
In kube-apiserver, Kubernetes Impersonation works like sudo -u <current-user> (switching identity) rather than merely rewriting an audit label while keeping Kite's permissions:
kube-apiserverfirst authenticates Kite's credential (e.g., Kite's ServiceAccount) and checks whether it hasimpersonatepermission.- Once verified,
kube-apiserverdiscards Kite ServiceAccount's own permissions (even if Kite's ServiceAccount is bound tocluster-admin) and evaluates Kubernetes RBAC (RoleBinding/ClusterRoleBinding) strictly against the impersonatedUserandGroups. - If the target cluster has no
RoleBindingorClusterRoleBindingmatching that user or any of their groups,kube-apiservertreats the user as unauthorized and returns403 Forbidden.
For every authenticated (non-anonymous) Kite user, Kite sends:
Impersonate-User:<impersonateUsernamePrefix> + user.UsernameImpersonate-Group:<impersonateGroupsPrefix> + groupfor each of the user's OAuth/OIDC or LDAP groups, plus the fixed groupkite:authenticated
kite:authenticated is a group name defined by Kite (similar to Kubernetes' built-in system:authenticated, but limited to users signed in through Kite). Kubernetes does not know about it in advance; it only takes effect if you reference it in a RoleBinding / ClusterRoleBinding. See Scenario 2.
Two Typical Usage Scenarios
Choose the setup below that matches how you want to manage permissions:
Scenario 1: Reuse Existing Native Kubernetes RBAC
When to use: Your cluster already maintains RoleBinding / ClusterRoleBinding rules for users or OIDC/LDAP groups (for example, engineers already access the cluster via OIDC + kubectl). You want Kite to enforce those exact cluster-native permissions without duplicating fine-grained rules in Kite, while recording real users in Kubernetes audit logs.
1. Target Cluster Setup
- Ensure Kite can
impersonate: If Kite's credential already usescluster-admin, no extra setup is needed; otherwise see Kite Credential Permissions. - No new per-user RBAC needed for Kite: Reuse your cluster's existing
RoleBinding/ClusterRoleBindingrules, such as:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: dev-team-edit
namespace: app-staging
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: edit
subjects:
- kind: Group
name: oidc:developers
- kind: User
name: oidc:[email protected]Namespace & Custom Resource Visibility
Under native Kubernetes RBAC, loading the namespace selector (GET /api/v1/namespaces) or resolving Custom Resource schemas (GET /apis/apiextensions.k8s.io/v1/customresourcedefinitions/<name>) also runs as the impersonated user and requires read permission on namespaces or customresourcedefinitions.
2. Kite Setup
- Enable Kubernetes Impersonation on the cluster, and set Username Prefix / Groups Prefix to match your existing bindings (e.g.,
oidc:in the example above). - Control cluster visibility and delegate resource RBAC: In Kite's RBAC Configuration, create a role (do not name it
admin, sinceadmingrants Kite platform admin settings access) with wildcard resource permissions on that cluster sokube-apiservermakes all resource-level decisions:
rbac:
roles:
- name: prod-k8s-rbac
description: "Allow access to production in Kite; delegate resource RBAC to Kubernetes"
clusters: ["production"]
namespaces: ["*"]
resources: ["*"]
verbs: ["*"]
roleMapping:
- name: prod-k8s-rbac
oidcGroups: ["developers", "sre"]
# Or allow all authenticated Kite users to see this cluster:
# users: ["*"]If you prefer Dual Authorization (intersection of Kite RBAC and Kubernetes RBAC), assign fine-grained Kite roles instead — requests will require permission in both systems.
Kite admins are impersonated too
Impersonation applies to every user, including Kite admin users. On an impersonated cluster, a Kite admin can only do what Kubernetes RBAC grants to their impersonated identity.
Scenario 2: Manage RBAC in Kite, Use Impersonation for K8s Audit Logs Only
When to use: You do not want to create or maintain Kubernetes RoleBinding rules for individual users or teams inside the cluster. You want to manage all multi-tenant roles and permissions inside Kite's UI (or config.yaml), and enable Impersonation solely so kube-apiserver audit logs record the real Kite operator (e.g., alice) instead of Kite's ServiceAccount.
Impersonation also changes some Kite behavior (no local cache, kubectl terminal disabled, and more). Review Behavior Changes before enabling it only for auditing.
Why You Don't Need Per-User Kubernetes RBAC Rules
Whenever Kite impersonates an authenticated user (whether logged in via Local Password, OAuth/OIDC, LDAP, or API Key), Kite automatically includes Impersonate-Group: kite:authenticated. A single static ClusterRoleBinding for this group gives every request sent through Kite the permissions it needs, while Kite RBAC decides who may do what.
Make sure nothing else can assert kite:authenticated
Kubernetes groups are plain strings, so kube-apiserver cannot tell whether a group came from Kite. Binding kite:authenticated to cluster-admin hands cluster-admin to anything that can present this group, for example:
- Any other subject allowed to impersonate groups;
- The cluster's own OIDC authenticator without
--oidc-groups-prefix, if your IdP has a group namedkite:authenticated; - A client certificate with
O=kite:authenticated.
Confirm none of these apply to the cluster before creating the binding below.
1. Target Cluster Setup
- Ensure Kite's credential has
impersonatepermission (already included if Kite usescluster-admin; see also Kite Credential Permissions). - Create one
ClusterRoleBindingin the target cluster grantingGroup: kite:authenticatedthe maximum scope Kite is allowed to manage (e.g.,cluster-admin):
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kite-impersonated-users
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: Group
name: kite:authenticated
apiGroup: rbac.authorization.k8s.ioAfter this one-time binding, adding or changing users, groups, or roles in Kite requires zero changes to Kubernetes RBAC in the cluster.
2. Kite Setup
- Enable Kubernetes Impersonation on the cluster (leave Username Prefix and Groups Prefix empty).
- Configure fine-grained roles and role mappings in Kite's RBAC Configuration as usual (e.g.,
viewer, namespace-scoped developer roles).- Unauthorized actions are blocked by Kite RBAC;
- Authorized actions are forwarded to
kube-apiserverwithImpersonate-User: <username>andImpersonate-Group: kite:authenticated, recording the real user underimpersonatedUserin Kubernetes audit logs.
Behavior Changes
On clusters with Impersonation enabled:
- All users are impersonated, including Kite
adminusers. Their effective permissions on the cluster come from Kubernetes RBAC. - No local cache: The
controller-runtimeInformer cache is disabled, so every read goes directly tokube-apiserverand API request volume increases. Tune client rate limits withKITE_KUBE_API_QPS/KITE_KUBE_API_BURSTif needed. Clusters without Impersonation keep using the cache. - Kubectl Terminal is disabled, because its helper Pod uses a static ServiceAccount token instead of per-user impersonation. Pod terminals (
pods/exec) and logs (pods/log) work under the impersonated identity. - Overview counts: If the user cannot list nodes, pods, namespaces, or services, the overview shows
0for that item instead of an error. - Scheduled tasks: Helm auto-upgrade tasks run as the user who last saved the task, and fail if that user is disabled or deleted.
- Prometheus metrics:
- Cluster-local URL (
.svc/.svc.cluster.local): requests go through the Kubernetes Service proxy as the impersonated user, who needsservices/proxyaccess to that Prometheus Service. - External URL: all users share one Prometheus client that does not use Kubernetes credentials, so queries are not restricted by Kubernetes RBAC.
- In both cases, PromQL results are not filtered per Kubernetes object.
- Cluster-local URL (
Enabling Impersonation
Impersonation is configured per cluster.
Option 1: Via Dashboard UI
- Sign in as a Kite admin and go to Settings -> Cluster Management.
- Click Add Cluster or Edit on an existing cluster.
- Turn on Kubernetes Impersonation and optionally set Username Prefix and Groups Prefix.
- Save changes.
Option 2: Via Configuration File / Helm Values
In config.yaml or inline Helm config.clusters:
clusters:
- name: production
inCluster: true
impersonate: true
impersonateUsernamePrefix: "" # e.g. "oidc:" for Scenario 1; leave empty for Scenario 2
impersonateGroupsPrefix: "" # e.g. "oidc:" for Scenario 1; leave empty for Scenario 2
default: trueKite Credential Permissions
With Impersonation enabled, Kite no longer needs a cluster-admin binding. Kite's own credential (without impersonation) is only used for:
| Purpose | Request | Permission |
|---|---|---|
| Cluster version | GET /version | Allowed by the default system:public-info-viewer binding |
| API discovery | GET /api, GET /apis | Allowed by the default system:discovery binding |
| Prometheus auto-discovery (only when no Prometheus URL is set) | List Services in all namespaces | Optional; failures are only logged |
Every other request uses the impersonated identity, so the credential only needs impersonate:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kite-impersonator
rules:
- apiGroups: [""]
resources: ["users", "groups"]
verbs: ["impersonate"]
# Optional: allow Prometheus auto-discovery
# - apiGroups: [""]
# resources: ["services"]
# verbs: ["list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kite-impersonator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kite-impersonator
subjects:
- kind: ServiceAccount
name: kite
namespace: kite-systemFor the cluster Kite runs in, you can set these rules through the Helm value rbac.rules instead. Only do this if every cluster that uses this ServiceAccount has Impersonation enabled.
impersonate is still a cluster-admin-equivalent permission
A credential that can impersonate any user and group can impersonate the system:masters group or built-in users such as system:kube-controller-manager. Kite refuses to impersonate system:* identities, but that is an application-level check: if the credential leaks, the impact is the same as leaking cluster-admin. The benefit of Impersonation is that day-to-day requests run as the real user and are authorized and audited by the cluster, not that Kite's credential becomes low-privilege.
In Scenario 2, the only group Kite needs to assert is kite:authenticated (plus system:unauthenticated if anonymous access is enabled), so you can restrict groups with resourceNames. This blocks impersonating system:masters, but users cannot be restricted the same way because usernames are dynamic:
rules:
- apiGroups: [""]
resources: ["users"]
verbs: ["impersonate"]
- apiGroups: [""]
resources: ["groups"]
verbs: ["impersonate"]
resourceNames: ["kite:authenticated"]Identity Mapping
- Username:
Impersonate-Useris<impersonateUsernamePrefix> + user.Username(never the editable display nameName). API Key users are impersonated as the API Key name. - Groups:
Impersonate-Groupincludeskite:authenticatedplus<impersonateGroupsPrefix> + groupfor each OAuth/OIDC or LDAP group. - Prefixes are per cluster, not per login provider: Local password, LDAP, and API Key users get the same prefix as OAuth/OIDC users.
- Anonymous Mode: If anonymous access is enabled, anonymous requests map to
system:anonymouswith the groupsystem:unauthenticatedonly (withoutkite:authenticated). - OAuth / OIDC Best Practice: Configure
usernameClaimto a stable, immutable identifier that users cannot freely change in your IdP (such as a corporateemailorsub), or prefer binding Kubernetes RBAC permissions to OIDC/LDAP groups.
Security Notes
- Reserved identities are rejected (fail-closed):
system:*,kubeadm:*, andkubernetes-admincannot be impersonated. Reserved groups such assystem:mastersare dropped from group claims, and reserved usernames are rejected with403 Forbiddenwithout falling back to Kite's own credentials. - Client-supplied impersonation headers are ignored: Kite always replaces any incoming
Impersonate-*headers with the signed-in user's identity. - Group name collisions: See the warning in Scenario 2 before binding
kite:authenticated. - Credential permissions: See Kite Credential Permissions.