簡體   English   中英

是否可以在沒有 RBAC 的情況下從 prometheus 獲取 pod 指標?

[英]Is it possible to get pod metrics from prometheus without RBAC?

我有一個 Kubernetes 命名空間,其權限有限,不包括ClusterRoleClusterRoleBinding的創建。 我想在命名空間級別監控資源消耗和 pod 相關指標。

例如,pod 健康和狀態、新 pod 創建、pod 重啟等。

盡管我可以通過公開/metrics並添加注釋prometheus.io/scrape: 'true'來為自定義指標創建應用程序級指標端點。

但是有沒有辦法在沒有Cluster RoleClusterRoleBinding的情況下在命名空間級別獲取resource consumption and pod-related metrics

可以從 kube-state-metrics 獲取命名空間級別的實體。

  1. 拉取kube-state-metrics的helm圖表: https://bitnami.com/stack/kube-state-metrics/helm

  2. 編輯 values.yaml 文件並進行以下更改:

     rbac: create: false useClusterRole: false collectors: - configmaps - cronjobs - daemonsets - deployments - endpoints - horizontalpodautoscalers - ingresses - jobs - limitranges - networkpolicies - poddisruptionbudgets - pods - replicasets - resourcequotas - services - statefulsets namespace: <current-namespace>
  3. 在 prometheus ConfigMap 中,添加一個具有以下配置的作業:

     - job_name: 'kube-state-metrics' scrape_interval: 1s scrape_timeout: 500ms static_configs: - targets: ['{{.Values.kube_state_metrics.service.name }}:8080']
  4. 創建角色綁定:

     apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: kube-state-metrics namespace: <current-namespace> roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: view subjects: - kind: ServiceAccount name: kube-state-metrics namespace: <current-namespace>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM