OpenShift中的Grafana监控界面无法完成登录

Grafana OpenShift

问题描述:
访问OpenShift默认的grafana无法跳转到OpenShift console界面。报如下错误:

{"error":"invalid_request","error_description":"The request is missing a required parameter,
 includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed."}

解决办法:

$ oc patch sa grafana -p '{"metadata":{"annotations":{"serviceaccounts.openshift.io/oauth-redirecturi.first":"https://grafana.apps.example.com:450"}}}'

解释说明:
因为某些原因,外部负载均衡器并没有使用与Router对应的80/443端口,而是使用了83/450端口。
默认情况下OpenShift oauth-proxy登录验证会传入clientId为应用的serviceaccount,它会将跳转链接与serviceaccount中的redirecturi校验。如果匹配则允许跳转,否则会报参数不合法的错误。

grafana serviceaccount的默认跳转相关的配置如下:

$ oc get serviceaccount grafana -n openshift-monitoring -o yaml
...
  serviceaccounts.openshift.io/oauth-redirectreference.grafana: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"grafana"}}'
...

它会从grafana Route中获取跳转链接,它与真实的链接(83/450)不匹配,所以会报出不合法的错误。
故而需要添加指定的认证链接https://grafana.apps.example.com:450

除了grafana外,其它OpenShift默认的服务也会出类似的问题,也可以通过同样的方法解决。
参考文档:
https://docs.openshift.com/container-platform/3.11/architecture/additional_concepts/authentication.html

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容