Rancher Monitoring Grafana 对接 KeyCloak
Rancher Monitoring 的 Grafana 目前不能与 Rancher 对接 RBAC,可以通过对接 KeyCloak 进行进行用户身份认证。
环境信息:
- Rancher: v2.9.5-ent
- KeyCloak: 26.4.5
- Rancher Monitoring Helm Chart: 104.1.4+up57.0.3
部署 KeyCloak
配置 KeyCloak
创建一个 Client:



在 Client 里创建三个 Role:

在 Client scopes -> grafana-dedicated 中,创建一个 Mapper:

在 Client scopes -> Setup 中,将 email/offline_access/profile/roles 设置为 Default:


创建三个 Group,分别赋予对应的 Client Role:



创建一个 User,将其添加到其中一个 Group 中,此处选择 editor:

回到 Client -> Client scopes -> Evaluate,选择刚刚创建的 User,在选择 Generated access token:

JSON 中如果包含以下内容,说明没问题:
1 | "roles": [ |
配置 Grafana 对接 KeyCloak
在 Rancher 中,安装/更新 Rancher Monitoring V2,并在 Edit YAML 中进行配置:
1 | ... |
安装/更新完成后,通过 Rancher/Ingress 访问 Grafana,点击右上角的 Sign in:

通过 KeyCloak 登录:


登录成功后,查看 Role 为 Editor,说明配置成功:

如果 Rancher 和 Grafana 对接的是同一个 Keycloak Realm,那么从 Rancher 跳转到 Grafana 后,点击 Keycloak 登录按钮时,无需再次输入凭证,就可以直接完成登录。
Rancher Monitoring Grafana 对接 KeyCloak
https://warnerchen.github.io/2025/11/20/Rancher-Monitoring-Grafana-对接-KeyCloak/
install_url to use ShareThis. Please set it in _config.yml.