本地使用windows + docker desktop 开发测试, 需要在这种环境下 安装 prometheus node exporter 如果是linux 的话 有些bug 应该可以避免
安装 Prometheus Node Exporter
首先使用helm 安装相关资源
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack
windows 下会直接报错
用 kubectl describe pod
可以看出来错误原因 windows下不能挂在到 / 这个路径
这个居然是 feature 不认可是bug
https://github.com/prometheus-community/helm-charts/issues/467
解决方法里面提供了一版,但是命令可能是在mac 下的, windows 需要稍微调整一下格式以及 deamonset 的名字
PS C:\Users\54650> kubectl get ds -A
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
default prometheus-prometheus-node-exporter 1 1 0 1 0 kubernetes.io/os=linux 22m
kube-system kube-proxy 1 1 1 1 1 kubernetes.io/os=linux 49d
把这里的 prometheus-promtheus-node-exporter
换成你的ds 名字
kubectl patch ds prometheus-prometheus-node-exporter --type=json -p '[{"op": "remove", "path": "/spec
/template/spec/containers/0/volumeMounts/2/mountPropagation"}]'
配置转发端口
默认的service 是 clusterIP 的, 本地测试时需要将他换成集群外可以访问的, 默认端口9090 也可以自行查看service
kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090
就可以在 http://localhost:9090
查看了