kubernetes - ETCD 向 Prometheus 认证数据

标签 kubernetes prometheus grafana

我正在努力弄清楚如何获得普罗米修斯 https://hub.helm.sh/charts/stable/prometheus收集 etcd 统计信息。我知道我需要为它设置 tls,但是很难找到没有手动附加 ansible 步骤的好方法。有没有办法在工作节点上获取 etcd 证书并将它们挂载到 prometheus pod?

最佳答案

关注 Monitoring External Etcd Cluster With Prometheus Operator您可以轻松配置 Prometheus 以从 ETCD 抓取指标。

We can do all of that by creating certs as kubernetes secrets and adding a tlsConfig to our service monitor. Let me walk you through the whole process.



步骤是:

1) 创建 etcd service
2) 创建/附加endpoints用于 etcd 服务

3) 使用适当的 tlsconfig 创建服务监视器。下面的例子
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    k8s-app: etcd
  name: etcd
  namespace: kube-system
spec:
  endpoints:
  - interval: 30s
    port: metrics
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client-ca.crt
      certFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.crt
      keyFile: /etc/prometheus/secrets/kube-etcd-client-certs/etcd-client.key
      serverName: etcd-cluster
  jobLabel: k8s-app
  selector:
    matchLabels:
      k8s-app: etcd

4) 创建 Etcd 客户端证书

5) 创建 Kubernetes Secrets 以及之前为 prometheus 和 etcd ca 创建的证书和 key 。这将允许 prometheus 安全地连接到 etcd。
例子:
kubectl -n monitoring create secret kube-etcd-client-certs --from-file=etcd-client-ca.crt=etcd-client.ca.crt --from-file=etcd-client.crt=etcd-client.crt --from-file=etcd-client.key=etcd-client.key

6) 更新 prometheus.yaml 以包含创建的 secret 的名称。

7) 部署 etcd-service、servicemonitor 和 prometheus manifests 到集群
kubectl apply -f etcd-service.yaml
kubectl apply -f etcd-serviceMon.yaml
kubectl apply -f prometheus-prometheus.yaml

享受

关于kubernetes - ETCD 向 Prometheus 认证数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58875102/

相关文章:

docker - 在Pod中获取 “ErrImageNeverPull”

kubernetes - 创建集群范围的服务帐户以连接 gitlab

从 Spring Boot 2.1.6 升级到 2.2.2 后,Prometheus 不导出 Kafka Consumer 数据

javascript - Prometheus summary.observe 方法有什么作用?

elasticsearch - Graphite 和 Elasticsearch 数据库相关性

docker - 不使用卷的情况下备份 docker

templates - 如何使用 Kubernetes yaml 文件设置动态值

prometheus - 如何在 Prometheus 中一次调用中执行多个查询

grafana - 如何使用 Prometheus 作为数据源使用变量引用另一个变量来制作 Grafana 模板?

grafana - 我可以使用 Grafana 表列出所有向 Prometheus 报告的节点吗?