[英]Is it possible to get pod metrics from prometheus without RBAC?
I have a Kubernetes namespace with limited privileges which excludes the creation of ClusterRole
and ClusterRoleBinding
.我有一个 Kubernetes 命名空间,其权限有限,不包括
ClusterRole
和ClusterRoleBinding
的创建。 I want to monitor the resource consumption and pod-related metrics on the namespace level.我想在命名空间级别监控资源消耗和 pod 相关指标。
Eg, pod health and status, new pod creation, pod restarts, etc.例如,pod 健康和状态、新 pod 创建、pod 重启等。
Although I can create an application-level metrics endpoint for custom metrics by exposing /metrics
and adding the annotation prometheus.io/scrape: 'true'
.尽管我可以通过公开
/metrics
并添加注释prometheus.io/scrape: 'true'
来为自定义指标创建应用程序级指标端点。
But is there a way to get resource consumption and pod-related metrics
on the namespace level without Cluster Role
and ClusterRoleBinding
?但是有没有办法在没有
Cluster Role
和ClusterRoleBinding
的情况下在命名空间级别获取resource consumption and pod-related metrics
?
It is possible to get namespace level entities from kube-state-metrics.可以从 kube-state-metrics 获取命名空间级别的实体。
Pull the helm chart for kube-state-metrics: https://bitnami.com/stack/kube-state-metrics/helm拉取kube-state-metrics的helm图表: https://bitnami.com/stack/kube-state-metrics/helm
Edit the values.yaml file and make the following changes:编辑 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>
In the prometheus ConfigMap, add a job with the following configurations:在 prometheus ConfigMap 中,添加一个具有以下配置的作业:
- job_name: 'kube-state-metrics' scrape_interval: 1s scrape_timeout: 500ms static_configs: - targets: ['{{.Values.kube_state_metrics.service.name }}:8080']
Create a role binding:创建角色绑定:
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.