rancher监控不显示监控数据问题

rancher版本:v2.5.8
k8s版本:v1.23.4

问题描述:
使用rancher管理k8s集群时,使用rancher搭建k8s集群监控,发现racher ui及grafana上的监控都不显示数据。

解决方法:
最终发现问题主要是BoundServiceAccountTokenVolume参数问题。可在kube-apiServer的配件文件中加入--feature-gates=BoundServiceAccountTokenVolume=false配置来解决此问题。配置文件路径一般在/etc/kubernetes/manifests/路径下。

原因描述:
具体原因可参考此issue:
https://github.com/rancher/rancher/issues/33465

grafana发送请求prometheus查询监控指标时,请求中会携带一个token,prometheus-agent容器会通过判断请求中的token是否和prometheus-agent的serviceAccount的 secret中的token一致来判断请求是否被认证。如果不一致,prometheus-agent将会创建一个新的apiContext,新apiContext中的namespaceSet包含项目中的所有token来自的namespaces。

上面提到的两个token在k8s v1.20版本中是相同的,但是在1.21以上版本是不同的。Prometheus-agent也找不到请求的token中的namespaceSet。

在k8s v1.21版本,BoundServiceAccountTokenVolume默认是enabled状态。虽然相同namespace、使用相同的serviceAccount,但是在不同pods上是不同的token,而且token每小时会变化。

posted @ 2022-04-13 16:20  bystanderC  阅读(422)  评论(1编辑  收藏  举报