我正在努力弄清楚如何获得普罗米修斯 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/