
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