首页 新闻 赞助 找找看

k8s prometheus 出错 "cannot list resource"

1
悬赏园豆:30 [已解决问题] 解决于 2020-01-16 23:11

在 k8s 集群中部署 kube-prometheus 后遇到下面的问题

查看 prometheus 日志:

kubectl logs prometheus-k8s-0 -n monitoring -c prometheus | tail

发现下面的错误:

Failed to list *v1.Pod: pods is forbidden: User \"system:serviceaccount:monitoring:prometheus-k8s\" cannot list resource \"pods\" in API group \"\" at the cluster scope

请问如何解决?

dudu的主页 dudu | 高人七级 | 园豆:31075
提问于:2020-01-16 23:00
< >
分享
最佳答案
0

在园子里的博文 PrometheusOperator服务自动发现-监控redis样例 中找到了解决方法,将 prometheus-clusterRole.yaml 改为下面的配置

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: prometheus-k8s
rules:
- apiGroups:
  - ""
  resources:
  - nodes
  - services
  - endpoints
  - pods
  - nodes/proxy
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - configmaps
  - nodes/metrics
  verbs:
  - get
- nonResourceURLs:
  - /metrics
  verbs:
  - get

重新部署即可

kubectl apply -f prometheus-clusterRole.yaml
dudu | 高人七级 |园豆:31075 | 2020-01-16 23:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册