代码之家  ›  专栏  ›  技术社区  ›  Vraj KisHore Rv

普罗米修斯不能监视库伯内特斯的所有豆荚

  •  -1
  • Vraj KisHore Rv  · 技术社区  · 6 年前

    所以当我把普罗米修斯部署到库伯内特斯的时候,我有3个名字空间,我在日志中看到了错误。无法监视所有名称空间。

    错误:

    \“system:serviceCount:development:default\”无法在群集作用域中列出终结点” level=error ts=2018-06-28321:22:07.390161824z caller=main.go:216 component=k8s_client_runtime err=“github.com/prometheus/prometheus/discovery/kubernetes/kubernetes.go:268:未能列出*v1.endpoints:已禁止终结点:用户\“系统:服务帐户:devops:default\”无法在群集作用域中列出终结点

    1 回复  |  直到 6 年前
        1
  •  0
  •   Kun Li    6 年前

    你最好使用一个服务帐户来访问库伯内特斯,并给予SA普罗米修斯所需的特权。如下所示:

    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
    

    假设您在kube系统名称空间中部署了prometheus。此外,您还需要在普罗米修斯部署文件中指定类似sa的“serviceaccount:prometheus”。