k8s之Kube-prometheus
asdas
本文不包含持久化存储,所以数据会随pod丢失,请自行搜索相关教程(其实就是我不会)
数据收集当然是prometheus
了,可是看到安装教程我人都麻了,又臭又长,经过不断搜索后终于发现kube-prometheus
可以理解成别人整合好的轮子,一键安装
prometheus
⟶
\longrightarrow
⟶prometheus-operator
⟶
\longrightarrow
⟶kube-prometheus
中杯
⟶
\longrightarrow
⟶大杯
⟶
\longrightarrow
⟶超大杯
首先按官方安装喜闻乐见的镜像拉不下来
# 失败的镜像
k8s.gcr.io/prometheus-adapter/prometheus-adapter:v0.9.1
k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.5.0
# 平替镜像
docker pull lbbi/prometheus-adapter:v0.9.1
docker pull bitnami/kube-state-metrics
# 打标签替换
docker tag lbbi/prometheus-adapter:v0.9.1 k8s.gcr.io/prometheus-adapter/prometheus-adapter:v0.9.1
docker tag bitnami/kube-state-metrics:latest k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.5.0
ok啦,这时候应该都running了吧,不出意外的话还是有意外node-exporter
还是没启动起来
Error: failed to start container "node-exporter":
Error response from daemon: path / is mounted on / but it is not a shared or slave mount
当你搜索了一圈发现这么个解决方案
kubectl patch ds monitoring-prometheus-node-exporter --type "json" -p '[{"op": "remove", "path" : "/spec/template/spec/containers/0/volumeMounts/2/mountPropagation"}]'
尽管你修改成你本地正确的参数指令却还是得到这样的提示
The request is invalid
找到资源文件nodeExporter-daemonset.yaml
手动修改吧
で,mountPropagation: HostToContainerの行を削除する(2箇所) 咦,为什么是日语呢,因为我是从一个日本网站上扒到的
然后重新apply
一下 ok 正常running
接下来试验下ingress-nginx
吧,正好把kube-prometheus
里的grafana等乱七八糟的用ingress暴露出来
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: prometheus-ingress
namespace: monitoring
spec:
ingressClassName: nginx
rules:
- host: grafana.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: grafana
port:
number: 3000
- host: alertmanager.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: alertmanager-main
port:
number: 9093
- host: prometheus.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: prometheus-k8s
port:
number: 9090
直接域名访问就完事了,全都ok啦,host文件 127.0.0.1映射域名不要忘记
更多推荐
所有评论(0)