简体   繁体   English

prometheus 无法监控 kubernetes 中的所有 pod

[英]prometheus cannot able to monitor all the pods in kubernetes

So i have 3 name spaces when i deployed prometheus on kubernetes i see the error in the logs.所以当我在 kubernetes 上部署 prometheus 时我有 3 个命名空间,我在日志中看到了错误。 it is unable to monitor all the name spaces.它无法监视所有名称空间。

Error :错误 :

\"system:serviceaccount:development:default\" cannot list endpoints at the cluster scope"
level=error ts=2018-06-28T21:22:07.390161824Z caller=main.go:216 component=k8s_client_runtime err="github.com/prometheus/prometheus/discovery/kubernetes/kubernetes.go:268: Failed to list *v1.Endpoints: endpoints is forbidden: User \"system:serviceaccount:devops:default\" cannot list endpoints at the cluster scope"

You'd better use a service account to access the kubernetes, and give the sa special privilidge that the prometheus needed.最好使用服务帐号访问kubernetes,并赋予prometheus需要的sa特殊权限。 like the following:像下面这样:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: prometheus

---

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

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: prometheus
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: prometheus
subjects:
- kind: ServiceAccount
  name: prometheus
  namespace: kube-system

Presumes that you deploy prometheus in the kube-system namespace.假设您在 kube-system 命名空间中部署了 prometheus。 Also you need specify the sa like ' serviceAccount: prometheus' in your prometheus deployment file .您还需要在 prometheus 部署文件中指定类似“serviceAccount: prometheus”的 sa 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从单独的Prometheus服务器监视kubernetes集群及其所有服务,节点和Pod - monitor kubernetes cluster and its all service, nodes and pods from separate prometheus server 只监控一个命名空间 pod - Prometheus & Kube.netes & cadvisor - Monitor only one namespace pods - Prometheus & Kubernetes & cadvisor 如何使用 prometheus 获取我的 kube.netes 集群能够拥有的 pod 数量? - How to get the number of pods that my kubernetes cluster is able to have with prometheus? Prometheus + Kubernetes - 即使短命,所有 pod 都会获得价值吗? - Prometheus + Kubernetes - do all pods get values even if short lived? prometheus 操作员没有抓取所有的 pod - prometheus operator is not scraping all pods 用于运行pod和节点的Kubernetes prometheus指标? - Kubernetes prometheus metrics for running pods and nodes? 将 kubernetes pod 指标导出到外部 prometheus - Export kubernetes pods metrics to external prometheus 如何将kubernetes pods标签添加到prometheus指标? - How to add kubernetes pods label to prometheus metrics? 无法删除所有 Kubernetes 命名空间 Cronjob 中所有被驱逐的 pod - Cannot Remove all evicted pods in all Kubernetes namespaces Cronjob 如何显示使用Golang客户端库从Kubernetes中运行的所有Pod中捕获的Prometheus中的自定义应用程序指标 - How to show custom application metrics in Prometheus captured using the golang client library from all pods running in Kubernetes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM